2016-09-19 21 views
0

私はPythonにはかなり新しく、whileループを使用しています。私は、ユーザーが文字の代わりに番号を入力すると、エラーメッセージが表示されるように検証を作成したいが、そのループ内で私がユーザの入力を確認する

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

を持っています。私は研究していた.isalphaの使用を見た。誰かが、これはwhie真のループを作成し、数字を入力するためのエラーメッセージに行くだろうか?

+0

参照:http://stackoverflow.com/questions/39488787/what-is-the-canonical-way-to-check-the-type-of-input/39489028#39489028 –

答えて

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) 
+0

は、私は完全にありがとうそれを得る!手紙が入力されるまで質問を再作成する方法はありますか? – Codee

0

これはなんですか?

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() 
関連する問題