python - 新列表输入不更新函数结果
问题描述
我对 python 很陌生,我最近开始了这个项目。我觉得我很接近但我不知道为什么当我输入一组新数字时我的值不会更新?我认为这是最后一个功能的问题。图片说明:
def cow_bull():
game=True
idx=0
cow=0 # Guessed a numb correctly in wrong place
bull=0 #Guessed numb correctly in correct place
count=1
while True:
n=(player_list("Enter your guess!: "))
while idx < len(n):
if n == game_list_official:
print("You WIN!!!, It took you", count, "attempt!!!")
break
elif n[idx] == game_list_official[idx]:
bull+=1
elif n[idx] in game_list_official and n[idx] != game_list_official[idx]:
cow+=1
idx+=1
count+=1
print("cow",cow,"bull",bull)
cow_bull()
解决方案
推荐阅读
- r - 使用 R 中的 delta 方法估计线性回归截距的标准误差
- r - ggplot axis order criteria not in dataframe
- extjs - 重置表单字段的原始值
- javascript - How can I pass function's return value as parameter?
- php - How can I use a result from a SQL-statement in second SQL-statement? | PHP
- angular - 表单控件不适用于 Angular Material Mat-select
- reactjs - FullCalendar React 工具提示
- c# - SQLConnection to MariaDB localhost via .NetCore
- azure - 使用 aspnetcore3 执行 Azure 函数 v2 时出现异常 - 系统找不到指定的文件。System.Private.CoreLib
- bash - mailx sending email to multiple accounts