Learn
Working with Lists in Python
Review

In this lesson, we learned how to:

  • Get the length of a list
  • Select subsets of a list (called slicing)
  • Count the number of times that an element appears in a list
  • Sort a list of items

Instructions

1.

inventory is a list of items that are in the warehouse for Bob’s Furniture. How many items are in the warehouse?

Save your answer to inventory_len.

2.

Select the first element in inventory. Save it to the variable first.

3.

Select the last item from inventory and save it to the variable last.

4.

Select items from the inventory starting at index 2 and up to, but not including, index 6.

Save your answer to inventory_2_6.

5.

Select the first 3 items of inventory and save it to the variable first_3.

6.

How many 'twin bed's are in inventory? Save your answer to twin_beds.

7.

Sort inventory using .sort().

Folder Icon

Sign up to start coding

Already have an account?