This challenge is similar to an earlier one. Remember, though, I want you to practice! You'll probably want to use try and except on this one. You might have to not use the else block, though.
Write a function named squared that takes a single argument.
If the argument can be converted into an integer, convert it and return the square of the number (num ** 2 or num * num).
If the argument cannot be turned into an integer (maybe it's a string of non-numbers?), return the argument multiplied by its length. Look in the file for examples.
What does it want me to do! I don't understand the question
Hey Ayub! The challenge wants you to write a function that takes a single parameter. This parameter can be a string or an integer. If it's an integer, you should return the square of that number (the number multiplied by itself). If it's a string however it wants you to return the string multiplied by the length of the string I.e. "test" * len("test") = "testtesttesttest").
Please write back if you need more help!
Miguel de Luis Espinosa38,920 Points
if they give you something that can be transformed into a number ( like the string "23456" ) then return 23456 * 23456
if they give you somehting that canNOT be transformed into a number (like the string "Pe3tita") then return "Pe3tita" multiplied by len("Pe3tita")