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

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -