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 trialFlore W
4,744 PointsSquared challenge: my code was validated but why wouldn't it return anything on the console?
My code for the function was validated, and I tried to implement it on the workspace, and call the function, but the console would not return anything. What am I doing wrong?
Here is my code:
def squared(arg): try: int(arg) except ValueError: return str(arg) * len(arg) else: return int(arg) * int(arg)
squared("tim") squared(5)
2 Answers
Steven Parker
231,275 PointsWhen you call your function, it returns a value but that in itself wont display anything unless you're typing it into the REPL command line.
Wrap the call in a "print" statement to see the output from running it:
print(squared("tim"))
print(squared(5))
Flore W
4,744 PointsThanks Steven! yes it works now