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 = 99 l = min(a) if l == k: print str(str(a.index(min(a))) * min(a)) elif l > k: print '1'+ ('0' * (k+1))Answer1:
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.