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 trialDavid Ton-Lai
3,268 PointsI'm not sure why I can't continue, this code works in my text editor.
I'm not sure why I can't continue, this code works in my text editor.
# EXAMPLES
# squared(5) would return 25
# squared("2") would return 4
# squared("tim") would return "timtimtim"
def squared(number):
try:
number = int(number)
result = (number * number)
print(result)
except ValueError:
result = (number * len(number))
print(result)
1 Answer
Mike Hickman
19,817 PointsHi David,
In the challenge it wants you to return the result instead of print it. This mix up happens a lot, so don't worry about it. Just know there is a difference. I don't know python syntax, but try replacing both of your prints with return instead.
Good luck,
Mike
David Ton-Lai
3,268 PointsDavid Ton-Lai
3,268 PointsWow of course, thanks so much Mike! Sorry to bother you with such a stupid question, I just need to be more careful.