Why is __name__ == "__main__" not working?

What's wrong with my code?

  • I'm teaching myself to program in Python and don't understand why this code is failing my tests. Can anyone tell me what is wrong? """ >>> nlist[2][1] 0 >>> nlist[0][2] 17 >>> nlist[1][1] 4 """ nlist = [[0, 1, 17],[1, 4], [0, 0]] if __name__ == '__main__': import doctest doctest.testmod() I'm getting the following message which doesn't make much sense to me **************************************… Failed example: nlist[1][1] Expected: 4 Got: 4

  • Answer:

    seems you have whitespaces after the '4' in your doctest which causes the comparison to fail.

Chanz Chanz at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.