python - How would I use a while loop so that if they enter a number it would ask them the again? -


fn = input("hello, first name?") firstname = (fn[0].upper()) ln = input("hello, last name?") lastname = (ln.lower()) 

i want fn on loop if enter number instead of letters, repeat question

i guess need this

final_fn = "" while true:     fn = input("hello, first name?")     if valid(fn):         final_fn = fn         break 

define validation method before it. example joran mentioned

def valid(fn):     return fn.isalpha() 

Comments

Popular posts from this blog

php - Auto increment employee ID -

php - isset function not working properly -

python - Evaluating the next line in a For Loop while in the current iteration -