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 trial

Python Python Basics (2015) Logic in Python Try and Except

Try & Except

I need you to make a new function, add. add should take two arguments, add them together, and return the total.

Not able to get where i am doing wrong.

Please help me out

trial.py
try:
    def add(num1,num2):
        return(num1+num2)

1 Answer

Jonathan Fernandes
PLUS
Jonathan Fernandes
Courses Plus Student 22,784 Points

Hey friend, I have a thought for you!

The challenge asks you to create a function and you are creating one and wrapping it in a try statement. Can you try the following for me and tell me what happens:

def add(num, num2):
    return num + num2

Let me know what you get!

Thanks Friend, I have done the task by following below steps def add(num1,num2): return(num1+num2)

Found no error this time....

Jonathan Fernandes
Jonathan Fernandes
Courses Plus Student 22,784 Points

Yeah, then the function definition in the try statement was throwing you off then.

Let me know if you have any more questions!