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

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 2,550 Points

Genuinely lost on this one!

I am struggling in general to recall the information to complete this quiz. I have re-watched all the info in this section and cant seem to find the info to complete this. Im just looking for a reference to information I can use to complete this problem or some sample code to jump start me on completing this. (The question pertaining to this code is in the top right corner under "View Challenge") Thank you in advance!!

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

3 Answers

rydavim
rydavim
18,813 Points

It looks like your code for the first task is complete and correct, so I'm assuming you're referring to the second part of the challenge. You'll need to check if the first character is A before printing.

Real Python has a good reference for all the basic string functions - including how to select by index.

If that doesn't help, let me know and we can try some hints to get you started. Good luck, and happy coding!


Update (Sep 24, 2020):

It looks like you two may still be having some trouble. Here is some additional pseudo-code to get you going.

for continent in continents:
  # check if the first character matches what you're looking for.
  # if item[index] == 'char value':
    print("* " + continent)
rydavim
rydavim
18,813 Points

I've updated my post to include some pseudo-code. If you still feel stuck, we can walk through a complete solution. Keep at it! 😊

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 2,550 Points

Ok so I cant seem to reference the index of the first letter. I BELIEVE my code is checking the first item in the list vs the fist letter in the item in the list? Sorry if that doesn't make sense. First week here!

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
  # check if the first character matches what you're looking for.
  # if item[index] == 'char value':
    if continent[0] == "S":
        print("* " + continent)
rydavim
rydavim
18,813 Points

You're nearly there. The challenge is looking for all of the continents that start with A, rather than S. The code syntax looks good, though! Nice job!

Awesome, thanks for the update

Shane Smith I am having the exact same problem. I am completing it the same way and cannot get to the next step and don't fully understand the error code. Did you work it out?

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 2,550 Points

I have not, I skipped it and it hasnt come up again yet in the next few courses on the track like I was hoping it would. If and when I go back to solve it I will make sure to follow up :)