mardi 1 août 2017

Python - Can't get "string.isalnum():" to work properly

I cannot get the code below to work properly. It works if the user enters numbers for the name and it prints the theName.isdigit. But if the user enters both numbers and letters, it accepts this and moves onto a welcome message that follows. Looking at this, is there a reason you can find why theName.isalnum is not working here but the one above is?

Thanks in advance guys!

theName = raw_input ("What is your name?? ")

while theName.isdigit ():

if theName.isdigit ():
    print "What kind of real name has just numbers in it?? Try again..."
elif theName.isalnum ():
    print "What kind of name has any numbers in it?? Please try again..."
elif theName.isalpha ():
    print "Ok, great"
    break
theName = raw_input ("What is your name?? ")

Aucun commentaire:

Enregistrer un commentaire