0

To sum up, I need to ask a question:

If the user doesn't introduce a str, I need the question to be asked repeatly until the use enter a str.

This is what I got so far.

x = input('What is your name? ')

if x != str
    x=input('Sorry, you need to introduce a str. What is your name? ')
Red
  • 26,798
  • 7
  • 36
  • 58

1 Answers1

1

I believe what you mean is that if the user doesn't input all letters, the program will keep asking for the user's name. You can use the method isalpha() for that:

x = input('What is your name? ')

while not [s.isalpha() for s in x.split()] == [True for s in x.split()]:
    x = input('Sorry, you need to introduce a str. What is your name? ')
Red
  • 26,798
  • 7
  • 36
  • 58