Ajax-loader-large-white
Python Lists and Dictionaries
For One and All

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

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

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

Each list item is assigned to the user-defined variable number in turn. All you need to do is print two times number in the body of the loop (the indented part).

The for loop will automatically execute your code as many times as there are items in my_list!

script.py