lundi 23 mai 2016

Python, how to add IF function in a For Loop? [duplicate]

This question already has an answer here:

I am new to Python and I need help. How do I add IF function into FOR loop? I am figuring out how to ask the users to enter again if they leave username empty.

Below is a block of code.

def register():
for
    # How do I make a loop that whenever username is NULL enter again?
    username = str(input("Please enter your username: "))
    if username == "":
        print("You have entered nothing. Please enter again")

    password = int(input("Please enter your password: "))
    if password is None:
        print("You have entered nothing. Please enter again")

return username, password

Thanks guys, PS: make it as simple as possible, if possible.

Aucun commentaire:

Enregistrer un commentaire