0

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.

2
  • 1
    You shouldn't rely on pastebin (which might expire or be offline while somebody reads your question), Just paste the code here on StackOverflow! Commented Dec 27, 2009 at 3:22
  • which version of python are you using ? there is a drastic difference between python 2.x and python 3.x, which may explain the SyntaxError, even after applying the modifications given by Ned Batchelder... Commented Dec 27, 2009 at 12:30

1 Answer 1

1

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"]:
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! I made the changes but I can't ask for another card the program halts, here's the new modified code: pastebin.com/m1346acd1 P.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, 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...!
Ah, all right. Sorry then. I didn't want to bloat the website with my stupid questions. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.