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 trialLucy xu
1,949 PointsInvalid syntax when I called the function
def sales (number): number=len(number) first_result=number*number print("The number{} squared is {}".format (number,first_result)
sales("good")
1 Answer
Grigorij Schleifer
10,365 PointsHi Lucy, can you specify the problem you are trying to solve?
I modified your code and post it here with some comments. Do you want to square the number of characters in the string argument that you are passing to the sales method?
def sales(number):
number= len(number)
first_result = number * number
print("The number {} squared is {}".format(number, first_result)) # a parenthesis was missing here
sales("good")
The sales method will print the argument length and its squared product. Be careful though, the len function will count empty spaces too.