Mark
Mark

Reputation: 511

SyntaxError: invalid syntax Why?

Ok this is weird... I'm trying to accomplish the following: if i have lost up to 2 times then bet = startingbet but if I have lost more than 2 times maximum of (5 times lost) then bet = bet * 2 if more than 5 times lost then bet = startingbet

                if losttwice <= 2:
                    bet = startingbet
                elif losttwice <= 5:
                    bet = bet * 2
                else:
                    bet = startingbet

also if possible can anyone help me to add one more thing to this. I would like to do a random 50% chance when losttwice <= 2 (when I lost 1-2 times) for it to be bet = startingbet or bet = bet * 2 based on 50% chance

Thanks a lot!

The error:

  File "scripy.py", line 153
    elif losttwice <= 5:
       ^
SyntaxError: invalid syntax

Upvotes: 0

Views: 383

Answers (1)

Blender
Blender

Reputation: 298582

You're mixing tabs and spaces. One tab is equivalent to eight spaces, so your code really looks like this to the interpreter (solid lines are tabs, dotted lines are spaces):

enter image description here

You have to keep your indentation consistent. Use just tabs or just spaces. PEP8 recommends four spaces, which is what most projects use.

Upvotes: 6

Related Questions