FAQ: Working with Lists in Python - Review


#1

This community-built FAQ covers the “Review” exercise from the lesson “Working with Lists in Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Review

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2

Step 5. Select the first 3 items of inventory and save it to the variable first_3 . I tried this, didn’t work. Opened hint and said select first 5 terms.


#3

Hints are not always solutions, just examples or suggestions.

What does your line 7 read?

first_3 = ...

#4

Yes, sorry, the hint was an example, my bad. However, the instructions are misleading; they ask for the first three items. I used first_3 = inventory[:2], which should select the three items with index 0, 1, and 2. The solution was first_3 = inventory[:3], which should, if I’m not mistaken, select the first 4 items (0, 1, 2, and 3).


#5

Like range(), the stop index is excluded from the slice. The above is correct as it takes index 0, 1, and 2.


#6

Oh. Thanks, should’ve paid more attention to the instructions…