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

Jimmy Jumaye
Jimmy Jumaye
3,417 Points

need some help

not getting the question at all can anyone point me in the right dirrection

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

    # Code goes here

2 Answers

Hi there,

You want to pull out each item in items with no brackets (not loopy()). Remember your colon, then print the item.

Make sense?

Stuart Wright
Stuart Wright
41,118 Points

There are two things to fix here:

  • you should be iterating over the variable called items in your for loop, not loopy(), which is the function name.
  • your print statement is indented too far. It should be a single tab or 4 spaces.

Edit: and a third thing as Steve points out is that you need a colon to begin the loop.

The for loop is indented by 6 spaces; the print statement is indented by a further 9. While not correct, that's not preventing the challenge passing. Fixing the colon and the iterable name passes the challenge. I'm not sure that's strictly correct - what's your view on the tab/spacing requirement, Stuart? I'm not a Python guy.

Stuart Wright
Stuart Wright
41,118 Points

Interesting. I do consider myself a Python guy and turns out I was wrong - the code works fine with the inconsistent spacing (although it's bad practice for sure!). You would definitely run into trouble with more complex code, as you'd have to make sure that any related branches were 6 or 9 spaces indented, respectively. Convention according to PEP 8 style guide is to use 4 spaces (not tabs). In practice, the tab key is used, but text editors and IDEs would automatically translate the tab keystroke to 4 space characters.

I agree. The PEP guidelines are clear enough. One for the guys to look at within these challenges. I'll raise it.

Stuart Wright
Stuart Wright
41,118 Points

The code runs correctly even on my local interpreter, so I guess the challenge is handling it correctly - I suppose it comes down to whether or not they want to force good style or not!

I'll leave it, then. The key learning has been dealt with here.