0

I'm fairly new to Python and I'm using a while True loop. Inside that loop I have

Sentence= input("please enter a sentence").lower().split() 

However I want to create validation so an error message appears when the user inputs a number instead of a letter. I was researching and saw the use of .isalpha. Would anyone where this would go in the whie true loop to create and error message for inputting numbers?

1

2 Answers 2

1
sentence = input("please enter a sentence").lower().split() for word in sentence: if not word.isalpha(): print("The word %s is not alphabetic." % word) 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you I completely get it! Is there a way to keep repreating the question until letters are inputted?
0

Something like this?

sentence = input("please enter a sentence: ").lower().split() while False in [word.isalpha() for word in sentence]: sentence = input("Do not use digits. Enter again: ").lower().split() 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.