Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Lists Using Lists Continental

Cannot figure out the way to print out the words starting with the same letter

I can't figure it out! I have tried pop and continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia'] for c in continents: print("* " + c[0,3,5,6]) i just keep getting a "string indices must be integers" i don't know what else to try. i might just be over complicating things, once someone replies with an answer i know ill be mad at myself for it being so easy

continents.py
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
# Your code here
for c in continents:
    print("* " + c.pop(1,2,4))

1 Answer

You are already looping through each of those continents in your for loop, so you don't need to list out all of the indeces in pop. For example, if you want to print all of the characters in this list:

my_list = ['a','b','c','d','e']
for item in my_list:
    print('* {}'.format(item))

use this same logic to print all of the continents. Remember, \n is used to move to the next line.