Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To teach for loops, I start with this example:

  word = "banana"
  for letter in word:
    print letter
It isn't a counter, but it makes it clear that print is happening for each part of the word. Then you can write programs using arrays and other counters.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: