4
Why does nobody talk about indentation in Python...
I kept getting these weird errors where my code would run halfway then just stop. Spent like 3 hours last Tuesday trying to figure out why a simple if statement wasn't working. Turns out I mixed tabs and spaces in my indentation... the Python interpreter just gives up without a clear error message. Has anyone else had this drive them crazy when they first started coding?
2 comments
Log in to join the discussion
Log In2 Comments
sarah1981mo ago
Actually, Python does warn you about mixing tabs and spaces, but the error message is indeed confusing for beginners.
3
river_scott1mo ago
First time that happened to me I spent a solid 20 minutes thinking I broke my computer somehow. Took a coffee break and came back to realize it was just a rogue tab mixed in with my spaces. Your mileage may vary but now I just set my editor to show whitespace and save myself the headache.
3