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 trialSARA PARACHA
233 PointsQuiz:Task2
Challenge Task 2 of 2 I'd like you to now only print continents that begin with the letter "A".
HINT: Remember that you can access characters in a string by index
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for c in continents:
c== A
print(c)
youssef b10ta
Courses Plus Student 2,755 Pointsyour code is good u need just to do use if statments and check if the first index on the c is == 'A' like this
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for c in continents:
if c[0] == 'A':
print(c)
1 Answer
Steven Parker
231,198 PointsHere's a couple of hints:
- to control other statements, use an "if" statement
- a literal string needs to be enclosed in quotes (like "A")
- variable "c" will contain the entire name, but you want to test only the first character
- individual characters can be selected from a string with indexing (a number in brackets)
SARA PARACHA
233 PointsSARA PARACHA
233 PointsPlease someone Help me in answering this question.I'm stuck