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

not sure how to do

help

breaks.py
items = []
for item in items: 
        print(item)
def loopy(items):

    if item == "a":
        continue


    # Code goes here

1 Answer

Ezra Siton
Ezra Siton
12,644 Points
  • First you don't call to any function (you only create empty array).
  • Second the loop needs to be inside the loopy function (not outside!)
  • Third you have syntax errors.
  • And last what about the "else:"? statement

Summary - read more about functions, loops and vars (This is very important issue!). Or see again the videos. https://www.tutorialspoint.com/python/python_functions.htm

Check you code her: https://repl.it/languages/python3

# create function with parameter "items"
def loopy(items):
    #loop throw the array "items"
    for loopitems in items:
        # If the character at index 0 of the current item is the letter "a", continue to the next one
        if loopitems[0] == "a":
            continue
        # Otherwise, print out the current member.
        else:
            print(loopitems) 

#Calling the Function 
loopy(["abc","xyz","yio","pol"])
# returns : xyz yio pol

#Second Call - by passing var
loopyloop = ["abc","xyz","aaa","pol"]
loopy(loopyloop)
# return: xyz pol