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 trialMaor Beeri
2,154 Pointsgot a problem
I get this message error and don't know what to do :( need someone's assistance
# EXAMPLES
# squared(5) would return 25
# squared("2") would return 4
# squared("tim") would return "timtimtim"
def squared (x):
try:
num = int(x)
except ValueError:
return num * len(num)
else:
return num*num
2 Answers
Steven Parker
231,236 PointsYou're very close! But when the exception occurs, the variable "num" does not get assigned. So the code in the exception block should work with argument "x" directly instead.
Dave StSomeWhere
19,870 PointsDouble check what you are doing to handle the exception and pay attention to the bummer error message, it is telling you the issue.
Maor Beeri
2,154 PointsMaor Beeri
2,154 Pointsoh now I understand thanks a lot!