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

List Filtering by String Information

The object is to filter the list by continents beginning with the letter "A" (this only applies for lines 7 down). No matter what I try it doesn't work. I've tried filter, lambda, and variants of the current code in the file. I can't get this to work and I'm sure I've hit the point where I'm missing something small.

I hate that Treehouse doesn't show you the Challenge answers for you to learn from your mistakes!

continents.py
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
# Your code here

for land in continents:
    print("* " + land)

start_letters = "A"    

for land in continents:
    if land.lower()[0] == " A":
        print(land)

3 Answers

Nevermind. I figured out where I had made it more complicated than needed.

Oskar Lundberg
Oskar Lundberg
9,534 Points
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']

for land in continents:
    if land.lower()[0] == "a":
        print("* " + land)

^This passes the challenge.

  • The challenge want you to only print out the continents who starts with the letter 'A'.
  • land.lower() will never be equal to an uppercase A. therefor you most use either .upper() or * == "a":* I hope this helps :D
Oskar Lundberg
Oskar Lundberg
9,534 Points

whopps, didn't see your Nevermind message before I replied. Glad you figured it out :)

Fidelis Chime
Fidelis Chime
6,077 Points

We're still using the phone_book, with the columns id, first_name, last_name and phone.

Imagine we're implementing the autocomplete feature for a search facility on the phone where a user can start typing a last name and suggestions will appear. Write a query to retrieve all values from the last name column where the last name value is present. Only retrieve the last_name column.

Fidelis Chime
Fidelis Chime
6,077 Points

please guys am struggling with the above question , pls assist if you can