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 trialJimmy Jumaye
3,417 Pointsneed some help
not getting the question at all can anyone point me in the right dirrection
def loopy(items):
for item in loopy()
print(item)
# Code goes here
2 Answers
Steve Hunter
57,712 PointsHi 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
41,120 PointsThere 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.
Steve Hunter
57,712 PointsThe 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
41,120 PointsInteresting. 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.
Steve Hunter
57,712 PointsI agree. The PEP guidelines are clear enough. One for the guys to look at within these challenges. I'll raise it.
Stuart Wright
41,120 PointsThe 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!
Steve Hunter
57,712 PointsI'll leave it, then. The key learning has been dealt with here.