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

Daron Anderson
Daron Anderson
2,567 Points

Need insight on how to Print out all the continents that start with an 'A'. the square brackets & parens. confuse me.

"There has to be one and only one obvious way to solve it" Thanks in Advance!!!

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

4 Answers

There is more than one way to do it. You could try startswith() as explained here

Have not tried it in the code challenge but very probably would not work because the challenge explicitly asks for an if-statement + the course teaches accessing the letters in a string with the [].

Daron Anderson
Daron Anderson
2,567 Points

I love the design of your website. @kris Nikolaisen. Is your methodology, "If it works it works?"

Hi Daron,

you need to use an IF statement before the print command in this second task of the challenge.

So... IF the first letter of the word is equal to "A" then - next line - print etc.

To check the first letter you need to index the first letter of the string.

Does that help a bit? Otherwhise I could write more tomorrow, need to go to bed now...

Happy coding!

Nils

Daron Anderson
Daron Anderson
2,567 Points

@Nils Kriedner Where does it ask for the if staement?

HI Daron,

just checked where I saw it and I can't find it.

Either I was halluzinating ;-) or I mixed it up with some other challenge (which is highly likely).

So sorry about claiming something without checking it up again. I was so sure I had read it in that challenges text.

Anyhow, you can definetely solve the challenge with an if statement, that's for sure. I just checked it.

Could you solve it in the meanwhile?

Nils

Daron Anderson
Daron Anderson
2,567 Points

Nils Kriedner I feel it I mix my syntax up with other languages sometimes.