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 Break

Vikshith Vishwanath
PLUS
Vikshith Vishwanath
Courses Plus Student 820 Points

Bummer! Try again! when i take shopping list challenge from the course.

Traceback (most recent call last): File "C:/D/python/Loopy_function.py", line 16, in <module> loopy() TypeError: loopy() takes exactly 1 argument (0 given)

getting this when i run through the comand prompt. i am using python 2.7.12

breaks.py
def loopy(items):
# Code goes here
    items = []

    while True:

        thing = input("> ")
        items.append(thing)

        if thing == 'STOP':
            break

    for thing in items:
        print(thing)

loopy()        

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The reason you're getting the current error is that you're calling the function is that you're calling it yourself but not sending it anything where you've defined it as taking one argument. The last line of your code loopy() is not needed as Treehouse will be calling your function and sending in the information as the argument.

Note: This will not fix the entirety of your code, but will get rid of this particular error.

Happy coding! :sparkles:

Also note that you are not using the same version of Python as the course material. You should update Python to 3.5x.

Vikshith Vishwanath
Vikshith Vishwanath
Courses Plus Student 820 Points

Thank you Jennifer.

I am still not able to get the output on this , still getting Bummer! Try Again! I installed 3.5.2 version of python and then run this i am not getting any error messages and also its not allowing me to enter the items into the list

def loopy(items):

Code goes here

items = []

while True:

    thing = input("> ")
    items.append(thing)

    if thing == 'STOP':
        break

for thing in items:
    print(thing)

loopy(thing)
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi! I was stating that the reason you were getting that particular error is because you're calling the function but sending no arguments. But you shouldn't be calling the function at all. Treehouse is going to call the function and send it a set of items which is taken by the function. Also, the input is unnecessary as nothing will be read in from the user. The items array should also not be there.

I'll show you my working code and then walk you through it.

def loopy(items):
    # Code goes here
    for item in items:
        if item == "STOP":
            break
        print(item)

Here we define a function named loopy which accepts a list coming in from Treehouse. For every "item" in the "items" list we're going to check if it's equal to "STOP". If it is, we break the loop. If it's not, we print the item. Hope this clarifies things! :sparkles: