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

Marco Otto
Marco Otto
5,342 Points

Python Basics: It does what it should but want be excepted...Or am I wrong?

Challenge Task: Skip item in items when 'a ' at index 0

This code below works on my computer (jupyter) but gives me a "Bummer!" in the Challenge :-(

Any ideas?

Salute Marco

breaks.py
def loopy(items):
  cnt = 0
  for item in items:
    cnt +=1
    if cnt ==1 and item == 'a':
       continue
    else:
      print(item)

2 Answers

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

You have to check if the first letter of the current item is the letter 'a', if it is you have to continue with the next iteration if it is not you have to print it out. You could do it like this:

def loopy(items):
    # Code goes here
    for item in items:
        if item[0] == 'a':
            continue
        print(item)

I hope that helps a little bit.

Marco Otto
Marco Otto
5,342 Points

Thanks Carlos,

I guess I just misunderstood the question/concept. It is the first letter of what ever is in index 0 not the first index 0 itself. Thus my example just worked for items = ['a','b','c'] but not for items = ['abc','adc','abc']

Go it! :-)