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
Post a Comment