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 trialRakhi Sawant
495 PointsMy first part of this code challenge is correct, I don't understand what's wrong in the second part?
When I copy the exact same code and then paste in the python shell everything is fine. But in code challenge it keep showing Try Again.
Here is my code:
def loopy(items):
# Code goes here
for something in items:
print(something)
if something == 'STOP':
break
def loopy(items):
# Code goes here
for something in items:
print(something)
if something == 'STOP':
break
Rakhi Sawant
495 PointsHey You can click on the "View Challenge" to go to the code challenge page there you can see what is the challenge. "View Challenge" is on the top right side .
Bapi Roy
14,237 PointsHere is correct code
def loopy(items):
# Code goes here
for something in items:
if something == 'STOP':
break
print(something)
You don not need to print STOP
Rakhi Sawant
495 PointsThanks Bapi Roy for help.
1 Answer
Steven Parker
231,269 PointsBe careful about testing a challenge in an external REPL.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
In this case, your code is printing first before it checks the word., so STOP
will be printed. But if you do the check before the print, your code will be able to stop first.
Rakhi Sawant
495 PointsThanks for this advice, I got it.
Bapi Roy
14,237 PointsBapi Roy
14,237 PointsYou need to post, what is said to you to do. Otherwise is hard to guess what is wrong.