🎙️
9

I was writing my Python loops backwards for a whole month

I kept getting weird errors in my first project, a simple number game, and couldn't figure out why. My friend in Boston finally looked at my screen and pointed out I was using 'for i in range(10, 0)' instead of 'range(10, 0, -1)' to count down. Has anyone else had a basic syntax thing trip them up for way too long?
3 comments

Log in to join the discussion

Log In
3 Comments
the_alice
the_alice1mo ago
Oh man, that range got me too when I was starting out. I spent a whole afternoon staring at a blank output because my loop just wouldn't run. It's one of those things that seems obvious once you see it, but the missing step argument is so easy to miss. What other little syntax traps have you found?
3
abbyg60
abbyg601mo ago
Missing a colon after a function definition is my personal favorite. The error message is never about the colon, so you just stare at the code you're sure is right. @the_alice is right that these things seem obvious later, but in the moment they feel like the language is just messing with you.
5
the_jordan
the_jordan1mo ago
Ugh, forgetting parentheses when calling a function gets me every time.
3