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
Learn

Great work so far. Let’s finish up by practicing with a few functions that take lists as arguments.

Instructions

1.

Define a function called count that has two arguments called sequence and item.

Return the number of times the item occurs in the list.

For example: count([1, 2, 1, 1], 1) should return 3 (because 1 appears 3 times in the list).

  • There is a list method in Python that you can use for this, but you should do it the long way for practice.
  • Your function should return an integer.
  • The item you input may be an integer, string, float, or even another list!
  • Be careful not to use list as a variable name in your code—it’s a reserved word in Python!

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?