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.

LEFFLER RAMEY
2,812 PointsI am having trouble calling the list "A" list items in this challenge.
I've tried [0, 3, 5, 6] in different methods, including creating a new list and calling that. I'm genuinely stuck on this portion and can't find any clarification in the video for calling list items by character. Much appreciated!
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for c in continents :
print("* " + c)
2 Answers

jb30
44,572 PointsTo get the first letter of the string c
, you could use c[0]
. You could then compare the first letter to 'A'.
Another way would be to use the startswith
method on your string, such as s.startswith('A')
which will give you either true or false.

LEFFLER RAMEY
2,812 Pointsfor c in continents :
if c[0] == "A"
print("* " + c)
I'm getting syntax error on what I thought would make total sense. Any help here with layout of proper syntax would be much appreciated, this is the first challenge that's left me stuck and i've been thinking on it since yesterday. I may not be built for this, haha.

jb30
44,572 Pointsfor c in continents :
if c[0] == "A":
print("* " + c)
You were missing the colon at the end of your if statement.
LEFFLER RAMEY
2,812 PointsLEFFLER RAMEY
2,812 PointsI'm just stumped here. I tried "if c[0] = "A" " and got a syntax error. We haven't learned anything about the "startswith" method yet. To be clear I have to call continents that start with an 'A' and list them. This exact method hasn't been taught in the video prior to this, I cannot figure a way around this. The hint says "HINT: Remember that you can access characters in a string by index".
jb30
44,572 Pointsjb30
44,572 Pointsc[0] = "A"
tries to assign the value"A"
toc[0]
.c[0] == "A"
compares the values.