我有这个程序:如何循环通过用户定义的函数?
word = input('Customer Name: ')
def validateCustomerName(word):
while True:
if all(x.isalpha() or x.isspace() for x in word):
return True
else:
print('invalid name')
return False
validateCustomerName(word)
我希望程序反复要求用户输入他们的名字,如果输入自己的名字说错了,例如,如果它在它已经屈指可数。 返回如果该名称是无效
输出有效和False:
Customer Name: joe 123
invalid name
预期输出:
Customer Name: joe 123
invalid name
Customer Name: joe han
>>>
我缺少的东西方案...谢谢
[询问用户进行输入的可能的复制,直到他们得到一个有效响应](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – SiHa