Python Forum
don't understand format of if/else statements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
don't understand format of if/else statements
#3
Oh excellent, ok. Can you give me a very brief example of how an elif would work?

Ok, I think I got it, but I don't know why it adds the next user input line of code when I don't want it to yet?

first_name = input("What is your name? ")

if first_name == "":
    print("Please enter your name: ")

elif first_name.lower() == "steve":
    print("You are the instructor")

else:
    print("Hi " + first_name + " You are a student")

print()

birth_year = input("What year were you born? ")
Output:
What is your name? Please enter your name: What year were you born?
Reply


Messages In This Thread
RE: don't understand format of if/else statements - by Colin999 - Sep-14-2020, 01:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help implmenting if/else or case statements for option to choose file format. samlee916 1 2,104 Jul-22-2020, 06:06 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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