Keep getting an error next to my equal sign in python

page: 1
0
<<   2 >>

log in

join

posted on Sep, 12 2012 @ 07:37 PM
link   
My teacher said not to put 2 parenthesis at the end and to only to put one but every time I try to run the code, a red mark shows up near my equal sign.

x = input("Enter an integer between 0 and 7:")

print("x")

print("x", end =(" \t")
print("x+1")

print("x", end =(" \t")
print("x+1", end =(" \t")
print("x+2")

print("x", end =(" \t")
print("x+1")

print("x")




posted on Sep, 12 2012 @ 07:57 PM
link   

Originally posted by Manhater
My teacher said not to put 2 parenthesis at the end and to only to put one but every time I try to run the code, a red mark shows up near my equal sign.

x = input("Enter an integer between 0 and 7:")

print("x")

print("x", end =(" \t")
print("x+1")

print("x", end =(" \t")
print("x+1", end =(" \t")
print("x+2")

print("x", end =(" \t")
print("x+1")

print("x")


Try: print("x", end="\t")



posted on Sep, 12 2012 @ 07:57 PM
link   
I think it should probably be:

print("x", end=" \t")

I don't think that syntax is supported in Python versions less than 3.



posted on Sep, 12 2012 @ 08:01 PM
link   
reply to post by Manhater
 


TBH i know nothing about python but i can program plenty of other programing languages , you clearly have 1 to many parenthesis on the line


edit on 12-9-2012 by PhoenixOD because: (no reason given)



posted on Sep, 12 2012 @ 08:04 PM
link   
lol, it looks all the same though., Okay, I'll try that. Thank you.

Nope, I took it out and it's still doing it by the equal sign. bah
edit on 12-9-2012 by Manhater because: (no reason given)



posted on Sep, 12 2012 @ 08:06 PM
link   
Which version of Python are you using?



posted on Sep, 12 2012 @ 08:16 PM
link   
Ill have a look for you
edit on 12-9-2012 by PhoenixOD because: (no reason given)



posted on Sep, 12 2012 @ 08:22 PM
link   
reply to post by xrevxoltx
 


3.5 Idle



posted on Sep, 12 2012 @ 08:23 PM
link   
reply to post by Manhater
 


I have found this post that might help. This person is a similar problem :



if Verbose:
print("Building internam Index for %d tile(s) ..." % len(inputTiles), end=' ')

the end='' is invalid syntax just curious as to why.. and what the author probably meant to do.

I'm new to python if you haven't already guessed.


python print end=' '

edit on 12-9-2012 by PhoenixOD because: (no reason given)



posted on Sep, 12 2012 @ 08:26 PM
link   
If I do it like this, it works, but then I can't get it to tab t


x = input("Enter an integer between 0 and 7:")

print x

print x
print x+1

print x
print x+1
print x+2

print x
print x+1

print x
edit on 12-9-2012 by Manhater because: (no reason given)



posted on Sep, 12 2012 @ 08:28 PM
link   
reply to post by Manhater
 


It compiled and worked fine for me. You do know that you are only printing strings, right?



posted on Sep, 12 2012 @ 08:30 PM
link   
reply to post by GreenGlassDoor
 


What worked fine for you?

I have to use print strings, input strings and format strings.



posted on Sep, 12 2012 @ 08:31 PM
link   
reply to post by PhoenixOD
 


Yeah, I have like 20 web pages for python for dummies.
I've seen that one.
edit on 12-9-2012 by Manhater because: (no reason given)



posted on Sep, 12 2012 @ 08:33 PM
link   
reply to post by GreenGlassDoor
 


I'm trying to tab it now the way my print strings are



posted on Sep, 12 2012 @ 08:37 PM
link   

Originally posted by Manhater
If I do it like this, it works, but then I can't get it to tab t


x = input("Enter an integer between 0 and 7:")

print x

print x
print x+1

print x
print x+1
print x+2

print x
print x+1

print x
edit on 12-9-2012 by Manhater because: (no reason given)


If this is working for you then you are working in a Python 2.X. The initial code was for a Python 3K environment.

The initial code however, because everything is in a quotation mark, is a string so it will do a literal print of "x+1" rather than the variable x plus 1.

To get a tab in Python 2 you need to concatenate the strings, such as:

print string(x+1)+"\t"



posted on Sep, 12 2012 @ 08:40 PM
link   
Oh, maybe my version is different from school then. bah humbug.

ok, I'll try to do a work around then. Thanks.

I had to change it again

x = input("Enter an integer between 0 and 7:")
y = x+1
z = x+2

print x

print x
print y

print x
print y
print z

print x
print y

print x



posted on Sep, 12 2012 @ 08:45 PM
link   
reply to post by GreenGlassDoor
 


Mine won't accept string, says it's no longer in use.



posted on Sep, 12 2012 @ 08:50 PM
link   
reply to post by Manhater
 


Sorry, I was translating it in English in my head while I typed. The command is print str(x+1)+"\t"



posted on Sep, 12 2012 @ 08:51 PM
link   

Originally posted by GreenGlassDoor
reply to post by Manhater
 


Sorry, I was translating it in English in my head while I typed. The command is print str(x+1)+"\t"


duh, I wrote it out. That's right. Let me try that.



Thxs.



posted on Sep, 12 2012 @ 08:54 PM
link   
Nope that didn't tab it. Just went into a straight line of numbers

print x

print str(x)+"t"
print y

print str(x)+"t"
print str(y)+"t"
print z

print str(x)+"t"
print y

print x

output
1
1
2
1
2
3
1
2
1
edit on 12-9-2012 by Manhater because: (no reason given)






top topics



 
0
<<   2 >>

log in

join