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

Need help with Index

I am stuck on task two. I am not sure which video showed this or where to reference to learn more about what I am doing wrong.

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

2 Answers

The index method may not be what you are looking for.

To get the first letter of a string/list, use [0].

>>> 'hello world'[0]
'h'
>>> [1, 2, 3][0]
1
>>> range(1, 2, 3)[0]
1

Try writing code with the following structure:

for continent in continents:
    if ... == 'A':
        print('* ' + continent)

Replace the ... with the correct code and it should pass. (Note that I don't provide the entire solution so that you won't just copy-and-paste)

I hope this helps.

Alexander thanks so much I have been stuck on that challenge for days trying many different ways to get .index to work. I had variants of if ... == 'A': even. As soon as I read what you wrote about references characters in a string that helped so much.