0
while True:
    try:
        name = str(input("Enter a name? "))
    except ValueError:
        print("Enter a string of letters only!")
        break
    finally:
        print("String value accepted,", name)
        break

That's my code but the error I'm encountering is that some numbers or numerical values can also be strings so how do I make that program accept only letters?

Quda
  • 1
  • str object as built in method to check if input contains digits etc.. – Volzy Nov 27 '21 at 20:44
  • What do you mean by *strings only*? A string may contain digits as well as alphabetic characters, e.g. `"Alec Baldwin 3rd"`. In fact it's possible a name could include a numeric character, though that is frequently disallowed by [relevant local law](https://www.dictionary.com/e/baby-name-laws/). – dbc Dec 15 '21 at 19:00
  • But if you want to check to see whether a string include numeric characters see [Check if a string contains a number](https://stackoverflow.com/q/19859282/3744182). – dbc Dec 15 '21 at 19:01

0 Answers0