A for loop is not limited to numbers. It works with any iterable, meaning any object that can hand out its items one at a time. Strings, lists, tuples, dictionaries, sets and ranges are all iterable. The syntax is always for name in iterable:, and on each pass the name is bound to the next item. The loop ends by itself when the items run out, so you never need a counter or an end condition.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.