Py学习  »  Python

python中for循环内的x=x+1语法错误

real_aravind • 6 年前 • 1385 次点击  

如果满足条件,我尝试在for循环中增加变量(count)。但是,我在increment语句中得到一个语法错误。请帮忙。

def count_ans():
    count=0
    for m in range(0,4):
        if quiz_dict[q_nos[m]==ans_list[m]:
            count += 1    #<--syntax error
return count
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43287
文章 [ 1 ]  |  最新文章 6 年前
Vikika
Reply   •   1 楼
Vikika    7 年前

功能应该是跟随

def count_ans():

count=0
for m in range(0,4):
    if quiz_dict[q_nos[m]]==ans_list[m]:  ##### Square bracket was missing
        count += 1   
return count                        #### Return was outside the function