For loops#

Learning Objectives#

After working through this topic, you should be able to:

  • Explain what a for loop is and list examples where it can be useful

  • Write for loops that iterate over:

    • Elements in lists and tuples

    • Keys, values or keys and values in a dictionary

  • Write for loops applying a manipulation to all elements in a container

  • Use for loops to sum up numbers in a list

Materials#

Video:

Download the slides.

Real Python tutorial on for loops. Note that this contains many things you do not need to know!

Quiz#