Reputation: 9
It won't print do not leave username blank as it is invalid input when I press enter(blank input)
def strchecker(question):
valid=False
while not valid:
user_Name = input(question)
if user_Name!="":
valid=True
return user_name
else:
print("Do no leave username blank")
print("*************Welcome to the Te Reo Maori Quiz***************")
user_Name = str(input("Please enter your username"))
Upvotes: 0
Views: 59
Reputation: 96
You haven't actually called the function; that's probably why it's not working. Try this:
def strchecker(question):
while True:
user_Name = input(question)
if user_Name:
return user_Name # Make sure to capitalize the N in user_Name
break
else:
print("Do no leave username blank")
print("*************Welcome to the Te Reo Maori Quiz***************")
user_Name = strchecker("Please enter your username")
This should work.
Upvotes: 1