G
20

Appreciation post: My first Python script printed something totally wrong for 2 hours

I wrote a loop to count to 10, but it kept printing '1' over and over. Turns out I put the print statement inside the wrong set of curly braces. Anyone have a good trick for keeping track of those brackets?
3 comments

Log in to join the discussion

Log In
3 Comments
stone.simon
Wait, curly braces in Python? That's honestly wild. You must have been writing in a totally different language by accident.
4
blake432
blake4321mo ago
Curly braces in Python? That's a new one. Are you maybe mixing up languages like JavaScript? Python uses indentation to show what's inside a loop. Getting the print statement's spacing right is the actual key.
2
nathanwalker
That indentation thing tripped me up for weeks.
6