私はPythonにはかなり新しく、whileループを使用しています。私は、ユーザーが文字の代わりに番号を入力すると、エラーメッセージが表示されるように検証を作成したいが、そのループ内で私がユーザの入力を確認する
Sentence= input("please enter a sentence").lower().split()
を持っています。私は研究していた.isalphaの使用を見た。誰かが、これはwhie真のループを作成し、数字を入力するためのエラーメッセージに行くだろうか?
私はPythonにはかなり新しく、whileループを使用しています。私は、ユーザーが文字の代わりに番号を入力すると、エラーメッセージが表示されるように検証を作成したいが、そのループ内で私がユーザの入力を確認する
Sentence= input("please enter a sentence").lower().split()
を持っています。私は研究していた.isalphaの使用を見た。誰かが、これはwhie真のループを作成し、数字を入力するためのエラーメッセージに行くだろうか?
sentence = input("please enter a sentence").lower().split()
for word in sentence:
if not word.isalpha():
print("The word %s is not alphabetic." % word)
は、私は完全にありがとうそれを得る!手紙が入力されるまで質問を再作成する方法はありますか? – Codee
これはなんですか?
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()
参照:http://stackoverflow.com/questions/39488787/what-is-the-canonical-way-to-check-the-type-of-input/39489028#39489028 –