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 Python Basics (2015) Shopping List App Continue

Virochaan Ravi
Virochaan Ravi
6,940 Points

Don't Understand CHallenge

Please help me understand and see the code involved in this challenge

def loopy(items):
    # Code goes here

2 Answers

28,558 Points

This challenge is actually quite similar to the earlier break challenge. The only difference is that you have to check a specific letter of the item, rather than the item itself. And that you have to use the continue keyword instead of the break keyword.

The continue keyword simply makes the loop skip an item. Pulling out a specific letter in a string can be done in the same way you pull out a specific item in a list by simply using bracket notation.

Here is an example of the solution:

def loopy(items):
    for item in items: # Loop though the items list
        if item[0] == "a": # Pull out the first letter of the item string (indexes start at 0)
            continue # Continue if the first letter is "a"
        print(item) # Print the item if that is not the case

If there is something you'd like more details on, or if you are still confused then feel free to ask me follow up questions, I'd be happy to answer anything I can.

#they are asking you to loop  the argument 'items '
#if the first character is 'a' pass, always the first character will at the index 0
#when It find an "a" just pass it
def loopy(items):
    for item in items:
        if item[0] == 'a':