Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Shopping List App Continue

Daniel Gajdos
Daniel Gajdos
3,817 Points

"bummer" error for CONTINUE challenge

Hi,

I tested my code in python console and it's working ok but here i received error "bummer". I am not sure whether I have something wrong or i misunderstood the task. Please could you help me? Thanks in advance.

breaks.py
def loopy(items):
    # Code goes here
    for item_index, item_value in enumerate(items):
        if (item_index == 0) and (item_value == 'a'):
            continue
        print(item_value)

3 Answers

Haider Ali
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Haider Ali
Python Development Techdegree Graduate 24,724 Points

Hi Daniel, I have taken a look at your code and seen that the challenge is actually a lot more simple than you think. enumerate() is not needed. Also, in python, parenthesis are not needed around your conditions unlike other languages such as JavaScript. This is what your code should look like:

def loopy(items):
    for item in items:
        if item[0] == 'a':
            continue
        else:
          print(item)
Daniel Thiessen
Daniel Thiessen
5,421 Points

I'm a bit confused by the temporary variable 'item' that is used in the for loop, how does 'item' have indexes when within the for loop it is the pieces of the list/string not the list/string itself. Can you clarify this?

Haider Ali
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Haider Ali
Python Development Techdegree Graduate 24,724 Points

When the loop is looping through items, item is simply the current item in items. this loop tells python to go through items and for each item, check if its index 0 is 'a'.

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

You should continue if item is the letter "a"

def loopy(items):
    for item in items:
        if item[0] != 'a':  # <-- reversed test to not 'a'
            print(item)
        continue  
Daniel Gajdos
Daniel Gajdos
3,817 Points

i was thinking too complicated. thank you both :)