首页 > 解决方案 > 新列表输入不更新函数结果

问题描述

我对 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()

标签: pythonlistfunction

解决方案


推荐阅读