Log in from a computer to take this course

You'll need to log in from a computer to start Learn Python 2. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

Passing a list to a function will store it in the argument (just like with a string or a number!)

def first_item(items): print items[0] numbers = [2, 7, 9] first_item(numbers)
  1. In the example above, we define a function called first_item. It has one argument called items.
  2. Inside the function, we print out the item stored at index zero of items.
  3. After the function, we create a new list called numbers.
  4. Finally, we call the first_item function with numbers as its argument, which prints out 2.



Change line 2 so that list_function returns only the item stored in index one of x, rather than the entire x list.

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?