Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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!

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):
        return int(num) ** 2
    except ValueError:
        return num * len(num)
Justin Lee
Justin Lee
Courses Plus 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? :)