from itertools import chain, repeat
word = "trick or treat" # This is the phrase a user needs to guess
prompts = chain(
["You meet a whitch with a cauldron full of candies, what do you say? \n"], repeat("Noope! "))
replies = map(input, prompts)
valid_response = next(filter(word.__contains__, replies))
print(valid_response)
错误:
"Chain has not attribute %s" % ident
^
SyntaxError: invalid syntax
1条答案
按热度按时间dsekswqp1#
您可以只使用
while
循环: