Python Python Basics (2015) Number Game App Squared

I do not understand what to do

What is this asking me?? I do not understand what it wants me to do. please help!

squared.py
def squared(num):

1 Answer

Sigurd Melsom
Sigurd Melsom
6,107 Points

They want you to use try except to check if num can be parsed to int. If not to return the value of num multiplied by the length of num.. Something like this might work.

def squared(num):
    try:
        return int(num) ** 2
    except ValueError:
        return num * len(num)
Justin Lee
Justin Lee
Pro Student 593 Points

hi, i don't quite understand why can't we set as

return len(num)**2

That's what i put and ofcourse it's wrong. can you please explain? :)