Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如果错误消息说赋值前引用了变量,这意味着什么?_Python_Python 3.x - Fatal编程技术网

Python 如果错误消息说赋值前引用了变量,这意味着什么?

Python 如果错误消息说赋值前引用了变量,这意味着什么?,python,python-3.x,Python,Python 3.x,这是一个程序,要求我执行以下操作:查找播放器名称并根据用户输入打印出一个输出,但是当我运行它时,会出现find==False和current 查找的检查是在完成搜索后完成的,而不是在内部完成 将当前声明为0。 从当前->0循环到最大值-1 发现是真的不是真的 托比亚斯·克是对的。你真正想要的是: def Q7(): names=['ben','thor','zoe','kate'] #the list of names Max = 4 found=False c

这是一个程序,要求我执行以下操作:查找播放器名称并根据用户输入打印出一个输出,但是当我运行它时,会出现find==False和current 查找的检查是在完成搜索后完成的,而不是在内部完成 将当前声明为0。 从当前->0循环到最大值-1 发现是真的不是真的
托比亚斯·克是对的。你真正想要的是:

def Q7():
    names=['ben','thor','zoe','kate'] #the list of names 
    Max = 4
    found=False
    current = 0
    Splayer = input("What plaer are you looking for? ")
    while found == False and current <= Max-1:
        if names[current]== Splayer:
            found = True
        else:
            current = current+1
        if found == True:
            print('yes, they have a top')
        else:
            print('no,they do not have a top score')

你的问题是什么?我们不明白。。。解释解释一下医生。。。解释消灭医生。什么是问题?循环前定义电流=0。这只是读错了。。。。。。或者只是在名称中使用find=Splayer。另外,==True是不必要的。当然,只是想帮助您处理当前代码@tobias_Ka事实上,这行不通。名称[4]不存在。你需要边走边说谢谢伙计我很感激你的帮助
def Q7():
    names=['ben','thor','zoe','kate'] #the list of names 
    Max = 4
    found=False
    Splayer = input("What plaer are you looking for? ")
    current = 0;
    while found == False and current < Max:
        if names[current]== Splayer:
            found = True
        current = current+1
    if found == True:
        print('yes, they have a top')
    else:
        print('no,they do not have a top score')
def Q7():
    names=['ben','thor','zoe','kate'] #the list of names 
    Max = 4
    found=False
    current = 0
    Splayer = input("What plaer are you looking for? ")
    while found == False and current <= Max-1:
        if names[current]== Splayer:
            found = True
        else:
            current = current+1
        if found == True:
            print('yes, they have a top')
        else:
            print('no,they do not have a top score')
names = ['ben', 'thor', 'zoe', 'kate']
player = input("What player are you looking for? ")
if player in names:
    print("Yes, they have a top score.")
else:
    print("No, they don't.")