Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.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 - Fatal编程技术网

未绑定堆栈错误,在分配前引用?python

未绑定堆栈错误,在分配前引用?python,python,Python,这是我在一个关于保龄球记分板的大型程序中使用的一些代码,我有一个几乎相同的代码片段,它可以完美地用最大值宣布胜利者,但是我在这一点上继续得到一个错误。上面说打印代码中的“minname”是在作业前引用的,但我一辈子都搞不清楚到底是怎么回事。仅供参考,这是python中的代码 print() #Print a message to declare the loser (min) for i in range(total-1): if bowlerscorelis

这是我在一个关于保龄球记分板的大型程序中使用的一些代码,我有一个几乎相同的代码片段,它可以完美地用最大值宣布胜利者,但是我在这一点上继续得到一个错误。上面说打印代码中的“minname”是在作业前引用的,但我一辈子都搞不清楚到底是怎么回事。仅供参考,这是python中的代码

print()
#Print a message to declare the loser (min)              
for i in range(total-1):
    if bowlerscorelist[i] < bowlerscorelist[i+1]:
        minscore = bowlerscorelist[i]
        minname = bowlernamelist[i]
print(minname, "got the lowest score with: ", minscore)
print()
#打印消息以声明失败者(分钟)
对于范围内的i(总计-1):
如果bowlerscorelist[i]

有什么帮助吗?

它没有输入if语句(条件不符合ofc),因此在分配之前会引用“minscore”和“minname”

minname = ''
minscore = 0
 for i in range(total-1):
    if bowlerscorelist[i] < bowlerscorelist[i+1]:
        minscore = bowlerscorelist[i]
        minname = bowlernamelist[i]
print(minname, "got the lowest score with: ", minscore)
minname=''
minscore=0
对于范围内的i(总计-1):
如果bowlerscorelist[i]
假设列表中没有任何条件为真的项目。很难说,您给我们的代码不是独立的,因此它将由于与您看到的问题无关的原因而失败(例如,它将为
总计
给出
名称错误
)。但我怀疑您可能从未进入for循环,因为
total-1<1
,或者您的
if
条件总是失败,因此
minname
从未分配给。