0

I'm starting to code and while trying to code I stumbled with a "SyntaxError: Invalid Syntax" on an elif statement. I haven't seen a problem with the indentation or an open statement, but I'm sure that I'm overlooking something.

The code is for a "Dr. NIM" game, as training for myself but now I'm stuck

                while ingame_balls > 0:
                    print("\nok then, how many balls are you going to grab?")

                    while statement == True:
                        Draft = int(input("remember, you can only grab up to three marbles, but not less than one (1, 2 or 3)\n"))

                        if Draft == 1:
                            ingame_balls = ingame_balls - Draft
                            print("\n",(ball*ingame_balls),"\n")
                            time.sleep(1)
                                
                            print("ok, my turn\n")
                            time.sleep(4)
                            ingame_balls = ingame_balls - 3
                            print(ball*ingame_balls)

                        break

                        elif Draft == 2:
                            ingame_balls = ingame_balls - Draft
                            print("\n",(ball*ingame_balls),"\n")
                            time.sleep(1)
                                
                            print("ok, my turn\n")
                            time.sleep(4)
                            ingame_balls = ingame_balls - 2
                            print(ball*ingame_balls)

                        break

                        elif Draft == 3:
                            ingame_balls = ingame_balls - Draft
                            print("\n",(ball*ingame_balls),"\n")
                            time.sleep(1)
                                
                            print("ok, my turn\n")
                            time.sleep(4)
                            ingame_balls = ingame_balls - 1
                            print(ball*ingame_balls)

                        break

                        else:
                            print("that's not suitable anwser\n")

The complete code it's a bit longer, but I'm having the problem with those elif statements.

I don't really know if it's necessary any other info, but if it's the case, please tell me.

Thank you

gscionti
  • 3
  • 2
  • 3
    You are not allowed to have any other statement on the same indentation level between the `if` and the `elif`. I guess the `break` should be indented. – Klaus D. Jun 29 '20 at 01:12

1 Answers1

0

break should be inside each if.

while True:
    if something:
        break
    elif other_stuff:
        break
Carlos Rojas
  • 334
  • 5
  • 13