1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Python

Connected

Exercise

List Methods

Strings are not the only Python types that have methods associated with them. Lists, floats, integers and booleans are also types that come packaged with a bunch of useful methods. In this exercise, you'll be experimenting with:

  • .index(), to get the index of the first element of a list that matches its input and
  • .count(), to get the number of times an element appears in a list.

You'll be working on the list with the area of different parts of a house: areas.

Instructions

100 XP
  • Use the .index() method to get the index of the element in areas that is equal to 20.0. Print out this index.
  • Call .count() on areas to find out how many times 9.50 appears in the list. Again, simply print out this number.