nzec runtime error in python

ぐ巨炮叔叔 提交于 2019-12-12 05:13:52

问题


This code works fine in my system. However, when i ran in in an online compiler+ debugger, it gave me a runtime(NZEC) error saying indentation in line4:if a.index(min(a)) is wrong. The solution I expect is that the outermost for loop needs to run 't' times. According to that my code has to be right. Please help me find the mistake. Also, if you can tell me when all will we get an NZEC error, it will help me a lot! Thanks in advance!

t = int(raw_input())
for i in range(t):
    a = map(int, raw_input())
    if a.index(min(a)) != 0: 
            if min(a) == 0:
            print a.index(min(a))
        else:
            print str(str(a.index(min(a))) * (min(a)+1))
    elif a.index(min(a)) == 0:
        k = min(a)
        a[0] = 99
        l = min(a)
        if l == k:
            print str(str(a.index(min(a))) * min(a))
        elif l > k:
            print '1'+ ('0' * (k+1))

回答1:


It looks like your code mixes tabs and spaces. That's legal in Python 2, but a very bad idea (it has become an error in Python 3). I suspect that the online interpreter you're running the code in is taking a stricter view, and considering it an error. It probably sees something similar to what Stack Overflow sees (your code didn't copy correctly into your question either).

You can troubleshoot the issue by running the Python interpreter with the -t flag which will emit a warning any time there's inconsistent tab usage, or -tt to make it an error. Many text editors have tools that will convert tabs to spaces which can help to fix the issue.



来源:https://stackoverflow.com/questions/17373344/nzec-runtime-error-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!