-1

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
6
  • Post the whole traceback, your code looks fine syntax wise. Commented Jul 3, 2013 at 23:06
  • @AshwiniChaudhary what you mean by traceback? File "scripy.py", line 153 elif (losttwice <= 5): ^ SyntaxError: invalid syntax Commented Jul 3, 2013 at 23:07
  • 1
    There is no syntax error here. You'll need to show us the text of the error you get (the traceback) and the portion of the code which actually caused the syntax error. Commented Jul 3, 2013 at 23:07
  • Indent issue? an elif without an if? Commented Jul 3, 2013 at 23:08
  • 1
    @AshwiniChaudhary looks like OP's problem was tabs versus spaces, can you revert your edit to leave them in? Is that even possible? Commented Jul 3, 2013 at 23:11

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

8 Comments

I always have issues with this how can I avoid those issues? Should I use python editor?
it seems like if 2 <= losttwicew <= 5: bet = bet * 2 else: bet = startingbet would be clearer.
@Mark Set your text editor to insert spaces instead of tabs. If you don't know how, search it...
@2rs2ts: And if your editor doesn't have the option, use another editor!
@blender thanks for the help it worked! any chance I can get some help how to add the option for 50% chance? It will be great :)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.