Python Forum
I need help with my game, help please?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with my game, help please?
#2
You can't have an elif on it's own like that. Also, the condition for the if and the elif are the same. Here's how if/elif works:

if spam == 1:
    do_something()
    do_something('silly')
elif spam == 2:
    spanish_inquisition()
else:
    stop_it()
Lines 2 and 3 only execute if the value of spam is 1. Line 5 only executes if the value of spam is 2. The last line executes if spam is neither 1 nor 2. All of this only works because of the indentation. The indentation indicates which code is executed by each of the statement. In between the if and the elif, everything must be indented, or you will get a syntax error.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: I need help with my game, help please? - by ichabod801 - Nov-16-2019, 02:53 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020