What the elif is this?
- The
elif
command (which stands for 'elseif') allows you to ask 2, 3, 4 or 142 questions using the same input! This command must be in a certain place. You can have as manyelif
statements as you want, but they must go in betweenif
andelse
and have the same indentation. Theprint
statements in yourelif
command need to line up with the indent of the otherprint
statements.
EXAMPLE :
print("SECURE LOGIN")
username = input("Username > ")
password = input("Password> ")
if username == "mark" and password == "password":
print("Welcome Mark!")
elif username == "suzanne":
print("Hey there Suzanne!")
else:
print("Go away!")
E
Comments
Post a Comment