Welcome to the Treehouse Community
Looking to learn something new?
Shamushideen SuleCourses Plus Student 2,509 Points
Second shopping list
My loopy function needs to skip an item. Loop through each item in items. If the character at index 0 of the current item is the letter "a", continue to the next one. Otherwise, print out the current member. Example: ["abc", "xyz"] will just print "xyz".
My solution: def loopy(items): items = ["abc", "xyz"] for item in items: if item == "a": continue print(item) else: break print(item)
def loopy(items): items = ["abc", "xyz"] for item in items: if item == "abc": continue print(item)
Henrik ChristensenPython Web Development Techdegree Student 38,319 Points
You are very close.
- you should not create a variable named items - items would be the argument.
- also, you would want to check if item == 'a' instead of checking item == 'abc'
def loopy(items): # loop through items for item in items: # if character at  == 'a' if item == 'a': # then continue continue # else print item print(item)