Python: unexpected error

Here are the links of the two codes:


They are basically the same. But I can’t figure out what’s wrong with it.
One is producing an IndentationError and the other one is running perfectly.
Please help me figure it out since I am a noob python programmer and thus, not so good at python.

I can’t see any indention error in the code. So it’s probably an invisible one. on most editors tabs and spaces are indistinguishable. But python sees a difference. So
don’t mix tabs and spaces in python.

Use an editor which converts tabs to spaces automatically or use one of them consistently.

1 Like

In the first code, you have mixed tabs and spaces! eg line 14 is indented using tabs, whereas line 13 is indented using spaces. Use the arrow keys to go over them.

Whereas in the 2nd code, you have used spaces consistently for indenting each line. For more see link on SO

Also see the python style guide Style Guide for Python Code

1 Like

Thanks man, I didn’t know that.

//