tags:

views:

57

answers:

1

This script won't compile. I wanted to made a simple 21-style game for practice but I get an error:

X@X:~/Desktop$ python 21.py File "21.py", 
line 18 
int(ptotal) = ptotal + newcard 
SyntaxError: can't assign to function call

Here's the code. Can anyone please help me? I'm obviously a beginner and the code is pretty sloppy.

+1  A: 

Not sure where you got this syntax:

int(cone) == random.randrange(1, 11)

I think you mean this:

cone = random.randrange(1, 11)

This is also an (interesting) invention:

while hit is not "No" or "no" or "n":

You'll need:

while hit not in ["No", "no", "n"]:
Ned Batchelder
Thanks! I made the changes but I can't ask for another card the program halts, here's the new modified code: http://pastebin.com/m1346acd1P.S. My strange syntax is due to me starting with C++, moving to Java, then jumping on boat Python yesterday. I've been trying to learn from random internet sources and sometimes they give out-of-date and/or incorrect information.
John Doe
@John, don't post multiple questions within one question. Your original question was answered successfully, so accept this one and open another -- posting your code in it, just as @Davide says -- that's how SO **works**, you know...!
Alex Martelli
Ah, all right. Sorry then. I didn't want to bloat the website with my stupid questions. Thanks.
John Doe