11
Question about my first Python project falling apart at line 47
Spent 6 hours building a simple calculator for my class project and the whole thing crashed when I tried to add decimals. My if statements kept skipping the float conversion and I had no clue why until a buddy pointed out my indentation was off. This is the third time tabs have messed me up and I'm starting to think I need a different editor. Does anyone else deal with these tiny syntax errors that eat up your entire afternoon?
3 comments
Log in to join the discussion
Log In3 Comments
wood.uma16d ago
Man what editor are you using right now? Because thats the real question here. I fought with Notepad++ for like two months thinking I was just bad at Python, but it turns out the editor was mixing tabs and spaces without telling me. Switched to something that shows invisible characters and it saved my sanity. Like legit highlight the whitespace so you can see if its a tab or 4 spaces. Have you tried looking at your settings to convert tabs to spaces automatically? Most editors have that option buried somewhere. Also double check if your class or whatever requires a specific setup cause some auto graders are picky about that stuff too.
10
baker.christopher16d ago
Sounds like you got the exact same treatment I did starting out. Wooduma is right about the editor being the real culprit here. Notepad++ got me too back in the day. It just quietly mixes tabs and spaces with no warning, and Python treats those as different things even though they look identical on screen. A good editor will either convert all tabs to spaces automatically or at least highlight the whitespace so you can see the dots versus the arrows. The other thing nobody tells beginners is that you can configure your editor to always insert 4 spaces when you press the tab key. That single setting would have saved you those 6 hours. Once you get that sorted, you'll stop fighting the tool and actually start learning the language.
3