V
26

Heard my kid's teacher explain loops with a sandwich and it clicked

I was at a parent teacher conference in Portland last Tuesday and she described a for loop as making 4 sandwiches with the same steps instead of writing the steps 4 times. I've been stuck on Python basics for 6 months after trying 2 online courses, but that one analogy finally made the text book code make sense. Has anyone else had a random real world example unlock something for them?
1 comments

Log in to join the discussion

Log In
1 Comment
jessica921
Ditch the sandwich analogy before it hurts you more than it helps. Real code has edge cases, empty lists, and weird user inputs that a sandwich will never prepare you for. Stick with boring examples like counting numbers or printing names, because that's what your first real debugging session will actually look like.
2