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 Functional Python Functional Workhorses Filter comprehension

how can i finish this thing

filters.py

filters.py
words = [
    'yellow',
    'red',
    'yesterday',
    'tomorrow',
    'maybe',
    'zucchini',
    'eggplant',
    'year',
    'month',
    'yell',
    'yonder',
    'today',
]

2 Answers

Steven Parker
Steven Parker
228,991 Points

The instructions are: Create a variable named y_words that uses a list comprehension to only contain the words from words that start with the letter "y".

It doesn't look like you've started yet, but some things you know need doing:

  • you need a variable name "y_words"
  • the variable will be assigned from a list comprehension
  • list comprehensions have brackets around them
  • part of a list comprehension will be similar to a loop
  • another part will be a conditional test
  • the condition needs to check the first letter of each word

Give it a try and if you still have trouble, show your code so far.

Amy Mou
Amy Mou
8,920 Points

Hi, you can check the first item on each string if it equals to 'y'

y_words = [word for word in words if word[0]=='y']