Learn

If you want to do something with every item in the list, you can use a for loop. If you’ve learned about for loops in JavaScript, pay close attention! They’re different in Python.

for variable in list_name: # Do stuff!

A variable name follows the for keyword; it will be assigned the value of each list item in turn.

Then in list_name designates list_name as the list the loop will work on. The line ends with a colon (:) and the indented code that follows it will be executed once per item in the list.

Instructions

1.

Write a statement in the indented part of the for-loop that prints a number equal to 2 * number for every list item.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?