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 trialfahad lashari
7,693 PointsI have no idea what I am doing wrong...code challenge[solved]
My code works just fine when I test in workspaces however it seems to not work here. Confusing. Can someone please let me know what I am doing wrong
# EXAMPLE
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"
import random
def random_item(tree_house):
print(tree_house[random.randint(0, (len(tree_house)-1))])
random_item("Treehouse")
jacinator
11,936 PointsMaybe mark the question as answered then. :) Good job doing your own debugging!
1 Answer
fahad lashari
7,693 PointsOops :p how do I do that?
jacinator
11,936 PointsThere should be a button beneath an answer that you can select that says something along the lines of "best answer".
jacinator
11,936 PointsIt just helps for people who are browsing over looking for questions to help on if they can see that this one is solved.
fahad lashari
7,693 Pointsfahad lashari
7,693 PointsDont worry guys i figured out my stupid problem. I forgot to change 'print' to 'return'. I was testing the code out in workspaces