FAQ: Code Challenge: Lists - Larger List

This community-built FAQ covers the “Larger List” exercise from the lesson “Code Challenge: Lists”.

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

Computer Science
Data Science

FAQs on the exercise Larger List

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!

why the else:
return lst2[-1]

Because the instructions are to make the code return the last item of lst2 (which you get with -1) in the case that the length of lst2 is higher than lst1.

Why is the solution different when I use lst1[ -1: ] vs lst1 [ -1 ] ? The output prints [ 5 ] vs 5 which is what the program is looking for.

Slicing and indexing are not the same thing.

A slice returns a list; a list element accessed via indexing returns the element.

Oh, ok. Thank you for the explanation.

1 Like