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,438 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.