13
My friend's kid in Seattle showed me how to fix a loop with a simple print statement
I was helping my friend's 10-year-old, Leo, with his first Python project last week, and he was stuck on a loop that wouldn't end. He kept saying 'it just keeps going' and was about to give up. I told him to add 'print(i)' inside the loop to see the counter, and his face lit up when he saw the numbers fly by and spotted the problem. Has anyone else found a simple trick like that to help someone see what their code is actually doing?
3 comments
Log in to join the discussion
Log In3 Comments
vera_campbell24d ago
Print debugging is a classic move (we all do it). Kinda surprised a 10-year-old needed that explained, though.
3
the_logan24d ago
Wait, hold on. The kid is ten? I guess I just assumed we were talking about a teenager or something. That's a whole different ball game. A ten-year-old figuring out print statements is actually pretty impressive. Most kids that age are still just playing games, not trying to fix their own code. Maybe the person explaining it was just surprised by how young they were.
10
blair24824d ago
Maybe we're all just 10-year-olds at heart.
5