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
#1
Hello, I'm using PythonAnywhere.com. I don't understand how to format these if/else statements so when the user doesn't enter their name, the result will ONLY be "Please enter your name." Instead it adds "Hi You are a student".

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

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

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

else:
    print("Hi " + first_name + "you are a student")
Output:
What is your name? Please enter your name: Hi You are a student
Reply


Messages In This Thread
don't understand format of if/else statements - by Colin999 - Sep-14-2020, 01:06 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,051 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