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 trialrakesh bhaskar
1,746 Pointseoferrror
same program when is run in workspace i got no error and result too
def square(a):
b=a*a
return b
number= int(input("enter an integer"))
sq=square(number)
print("the square of {} is {}".format(number,sq))
2 Answers
Steven Parker
231,248 PointsThere's no error when running this alone, but it doesn't meet the challenge criteria. In particular, the challenge instructions say "should define a single parameter named number", but the argument of this function is named "a" instead.
Then for task 2, the instructions say "call your new function and pass it the argument 3 ", but this code is requesting input from the console instead.
The instructions also say "create a new variable named result to store the value", but this code is storing it in a variable named "sq" instead.
Finally, the instructions don't require you to "print" anything.
rakesh bhaskar
1,746 Pointsthank you
Jason Anders
Treehouse Moderator 145,860 PointsChallenges are very specific with the instructions. For the second task, you are not asked to create any input or to print anything to the console. All that code should be deleted and only the code being asked for should be entered.
The second task simply wants a function call stored to a specific variable. So, you'll need to go back to the instructions and only code what you need for the task.
In regards to Shahar's comment, spacing doesn't normally have an effect on the code compiling, but proper practices with spacing is important when coding for readability and consensus throughout the community. A great reference is the PEP 8 Style Guide for Python
Keep Coding! :)
rakesh bhaskar
1,746 Pointsthank you
shahar ben-david
206 Pointsshahar ben-david
206 Pointsi am pretty new to coding but seems like u missing a space between the number = int and sq = square not sure tho :p