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 trialMisha Morse
3,711 PointsStuck on this challenge
I've tried everything I can imagine here. Just not sure what to do. I need to print indices 0,3,5,6 from this continents list in a bulleted fashion. The code here is my best guess
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for (continents[0,3,5,6]) in continents:
print ("* " + continent)
1 Answer
Ryan Groom
18,674 PointsMisha Morse So the challenge was actually asking that you print all elements of the array that begin with an "A", not specifically the elements at 0, 3, 5, and 6. This is why your code is not passing the test. One way to go about this solution would be as follows:
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
if (continent[0]) == "A":
print ("* " + continent)
This code loops through all of the continents in the array and checks if the character at the 0th index (the first character) is equal to "A", and if that is the case then it will print the content with the asterisk in front of it. Hope this helps! let me know if you need any clarification!
Misha Morse
3,711 PointsMisha Morse
3,711 PointsThankyou so much Ryan