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 trialFHATUWANI Dondry MUVHANGO
17,796 Pointsplease don't laugh at me
this is as far as i can get. im struggling to figure out how to make my code to convert and argument into a string. the rest i thing i can manage
# EXAMPLES
# squared(5) would return 25
# squared("2") would return 4
# squared("tim") would return "timtimtim"
def squared(item):
if item
1 Answer
Ryan S
27,276 PointsHi Fhatuwani,
To convert an argument into a string, you would use the str() function, however you don't need it in this challenge.
If you try to convert a string of non-numeric characters to an int, it will give you a ValueError. In this challenge they want you to use the try: and except: blocks to handle that error. The ValueError case would be for dealing with non-numeric strings.
Hope this helps.