Why doesn't the code work?/variable problem

if answer == "Nein": level == 3 ,print ("ok antwortet der mann aber dann kämpfen wir!")
if level == 3: print ("EIN KAMPF BEGINNT")

I cut out a part of the code the variables exist and there is no error message The if level == 3 doesn’t work please help me :grin:

Hi !

You have some critical syntax errors here !

  1. level == 3 is for checking if the level variable has the value 3, I guess what you want is level = 3 to affect the value 3 to level.
  2. To perform several actions on a single line of code, you have to use ;, not ,.

I would suggest you to split your if statements into several lines, instead of trying to fit everything on one single line. Your code would be easier to read and to debug. See 4. More Control Flow Tools — Python 3.12.1 documentation for examples.

1 Like

Ah thank you very much! I will fix this😄