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 trialHector Carrillo
934 Pointswhy isnt it printing the correct "items"
added stop code
def loopy(items):
for things in items:
if things == 'STOP':
break
else:
print(items)
1 Answer
Alexander Davison
65,469 PointsYou are printing items
in the else
statement. You should print things
.
Also, it's best to have non-plural names for "temporary variables" used in loops.
The name item
is probably a better, easier-to-understand name than things
. Even the non-plural thing
is better than the plural things
. Again, you don't have to do this, but if your code is cleaner with better names, it is easier to not make bugs in your code. Also, it's easier to add features if you are on a big project
I hope this helps. ~Alex
Hector Carrillo
934 PointsHector Carrillo
934 Pointsyeah true, i see the error. thanks again really going to implement that to my future temp. variables
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsNo problem