PlZ HELP ME WITH THE ANSWER
i'am not able to determine what to do in the question if somebody can send me his/her code to this solution it would be a great help...
# EXAMPLES # squared(5) would return 25 # squared("2") would return 4 # squared("tim") would return "timtimtim" def squared(square): if square == int(): return square*square elif square == str(): return len(string)*len(string)
Sathvik Koneru6,314 Points
The elif argument doesn't seem to make sense. The len() function gets the length of the string which in the case of a single-digit number would be 1. Moreover, you should be passing square instead of string here, as square is the parameter passed into this method. Instead what you want to do is use the int() method to unpack the string into an integer. For example:
>>>s = "5" >>> int(s) 5
Use this approach to convert the string to an int and complete the elif statement.
Matt HansonTreehouse Moderator 17,002 Points
Hi there. There was another post about this challenge a few minutes ago with a good explanation, here's a link.