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 trialLalit Aditya
400 PointsI need you to make a new function, add. add should take two arguments, add them together, and return the total.
What is the mistake in my code?
def add(num1, num2):
return num1+num2
total=num1+num2
total= add(3, 4)
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! You are doing fine, but you added some extra things to the code. The third line total = num1 + num2
. Will cause a syntax error. The variables num1
and num2
are defined only in the function and not available outside the function. But your actual function definition and the code in it is just fine. Simply removing the last 2 lines of your code causes this to pass Step 1 of the challenge.
Hope this helps!