Python Introducing Lists Using Lists Continental

christopher Junkins
christopher Junkins
1,357 Points

Getting right output for indexing but not able to pass the question

I'm getting the right output but guessing its the not way they want. I guess they want me to use the continent[0,3,5,6] but not sure how to get a whole item from a list added and not just the first letter of the string.
continents = [
    'South America',
    'North America',
for continent in continents:
    if continent[0] == "A":
        print("*" + continent)
christopher Junkins
christopher Junkins
1,357 Points

I just passed it. it wanted to see the space after the * and before the " to make the output not looked squished.


If someone can give me the right procedure to pull an item from the list that would be great. for example: I wanted to list Asia and Africa, what would I use because using print(continents[0,3] will just output the first and 4th letter from every item.

1 Answer

James Joseph
James Joseph
2,438 Points

If you want to remove an item from one list and put it in the other you can use pop.

separate = [continents.pop(0), continents.pop(2)] 

Notice that I did 2 and not 3 on the second one. This is because it iterates through each one after each other. After I've poped out Asia, Africa would then take it's place in the index of 2.

More information on pop and other data structures: