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
Laknath Gunathilake1,860 Points
can't seem to pass this challenge
I'm not sure if I understand this question correctly, but I can't seem to pass the challenge
# EXAMPLES def squared(): # squared(5) would return 25 try: square=int(number)*2 return square except: square= str(number)*2 return square # squared("2") would return 4 # squared("tim") would return "timtimtim"
Gavin Ralston28,770 Points
def squared(you_need_to_set_a_parameter_here): # squared(5) would return 25 try: square = int(number)**2 ## check you're using two *'s and not just one, so you raise to a power instead of multiply return square except: return number * # times the length of the number variable, which is NOT an integer
Also, be sure to check your indentation. Assigning square a value and returning square don't require additional indents.
You'll need to add the last bit yourself, but I commented what you need to do to pass.
Remember, he's asking you to square the value if it's an integer, otherwise you're doing that python thing, where you multiply the string or whatever by printing it x number of times. So if somebody passed it "aaa" you'd want to return "aaaaaaaaa"
Hope that helps a bit!