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!
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 trial
dont get it
# EXAMPLES # squared(5) would return 25 # squared("2") would return 4 # squared("tim") would return "timtimtim" def squared(a): try: return int(a) * int(a) except ValueError: print("") squared("2")
Dan Garrison22,457 Points
Your statement in the try code block is fine, but you still need to handle the situation where you can't convert the argument into an integer in the except code block (You also don't need to include TypeError in the Except block). The instructions say that if you can't convert argument to an integer then you need to multiply the argument by the length of the argument. Remember the method for checking the length of something in python is len().
Yes, in the exception block the only line needed is either: print (a * len(a)) or return (a * len(a)) depending on whether or not the instructions require the value to be printed or returned.
I meant "try writing this line of code in the exception block", not add a "try" in the exception block.
My apologies for the confusion.