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 trialSeamus Hannan
509 Points"Try and Except"tutorial, stuck
this is super basic and im sure its just some syntax error or something specific to the tutorial but I cant figure out what.
its just supposed to define a function that takes two arguments, adds them, and returns the result.
I keep getting "Bummer! Try again!" which is super helpful/s.
def add(x,y):
x+y=z
return z
1 Answer
Colton Ancell
1,636 PointsIn Python, you have to keep the variable that you're assigning to on the left side of the =
operator, and any computations on the right side. So, in your case, it's just a matter of switching x+y=z
to z=x+y
. Hope this clarifies things for you!
Seamus Hannan
509 PointsSeamus Hannan
509 Pointsthanks! it also wanted me to write it as:
and in the next part:
(I figured out how to format these!)