Checks if the user entered the correct username
def validate_user(username):
if username != "coder43" and username != "goodHacker90" and username != "baseball45":
return False
else:
return True
Gets the user's username
def get_username():
while True:
username = input("Enter your username: ")
if validate_user(username):
print "Welcome!"
return username
else:
print "That's not a valid username. Try again"
print "Welcome to CodeHS!"
get_username()
A) Welcome!
B) That's not a valid username. Try again
C) Enter your username:
D) coder43

Q&A Education