Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Using Lists Continental

Farhan Murad
Farhan Murad
1,920 Points

List

I do not know how to print only Asia and South America from this list. It is supposed to look something like this: "* Asia

  • South America"
continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
continents.pop(0,1)

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,716 Points

You are close! Python pop() method works only on one element at at time.

documentation here:

https://www.programiz.com/python-programming/methods/list/pop

One way to do this is below. However, continents is altered and will no longer have the first two elements of the list after you run the code.

Since pop(0) removes the FIRST element of the list, you call it twice.

print(continents.pop(0))
print(continents.pop(0))

A non-deleting method to acheive the task is below:

print(continents[0])
print(continents[1])

Good luck with your Python journey, there are a lot of cool apps waiting for you to build!