79443

nzec runtime error in python

Question:

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))

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.

Recommend

  • OpenMP with matrices and vectors
  • What is the order of execution in try,catch and finally [duplicate]
  • parsing invalid JSON Swift 4
  • PostgreSQL to XML with 3 Tables
  • Back press fragments issue in android
  • Safari PHP form submission -file upload hangs
  • Is a .txt file created in VB different than one I'd randomly create?
  • Best practice for switching iPhone views?
  • Regex for Specific Tag
  • How can we prepend rows to a react native list-view?
  • In-place sed command not working
  • What's the purpose of QString?
  • Eloquent paginate function in Slim 3 project using twig
  • Jackson Parser: ignore deserializing for type mismatch
  • Mysterious problem with floating point in LISP - time axis generation
  • How to know when stdin is empty if it contains EOF?
  • Atlas images wrong size on iPad iOS 9
  • Can I check if a recipient has an automatic reply before I send an email?
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Excel - Autoshape get it's name from cell (value)
  • Check if a string to interpolate provides expected placeholders
  • ActionScript 2 vs ActionScript 3 performance
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • align graphs with different xlab
  • Return words with double consecutive letters
  • SVN: Merging two branches together
  • RestKit - RKRequestDelegate does not exist
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Traverse Array and Display in markup
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Bitwise OR returns boolean when one of operands is nil
  • python draw pie shapes with colour filled
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Is there any way to bind data to data.frame by some index?
  • Reading document lines to the user (python)
  • How can i traverse a binary tree from right to left in java?
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal