bird_names="kiwi, hawk, crow, penguin"
count=0
bird_guess=input("Guess the name of the bird that may be in the secret list.You will only get 3
chances")
while count<3:
if bird_guess.lower() in bird_names.lower():
print("Congrats! Correct guess!")
break
else:
count=count+1
ans = str(3 - count)
下面提到的语句包含了一些我无法理解的问题,它显示了TypeError,说raw_input()接收了1到2个位置参数,但给出了4个。
bird_guess=input("Wrong guess! Try again! Only",ans,"chances are left!")
它显示TypeError,说raw_input()需要1到2个位置参数,但却给了4个。
看起来你是想做字符串连接,把你的输入改成。
bird_guess=input("Wrong guess! Try again! Only " + str(ans) + " chances are left!")
或者你可以使用字符串插值法,比如说
bird_guess=input(f"Wrong guess! Try again! Only {ans} chances are left!")