Omprakash Panigrahi9,632 Points
Code works on system but not on the quiz site
The code returns the correct results when run on a python compiler in the pc but it doesnt work when i try to submit my code.
# EXAMPLES # squared(5) would return 25 # squared("2") would return 4 # squared("tim") would return "timtimtim" def squared(item): try: return int(item ** 2) except: length = len(item) return item*length
I just tried this in the try block and it worked for me: return (int(item) ** 2)
Because you first need to turn the item into an int if you are going to be able to square it.
If you leave it like this: return int(item ** 2)
it will do whatever is inside of the parentheses first. Which could mean trying to square a string, which would not work