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! While you're at it, check out some resources Treehouse students have shared here.
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 trialAyub Muhammad
Courses Plus Student 4,345 PointsI 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
6,107 PointsThey 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
Courses Plus Student 593 PointsJustin Lee
Courses Plus Student 593 Pointshi, 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? :)