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

Prem Yadav
Prem Yadav
7,346 Points

Not getting where i'm doing mistake...........

I have successfully run the same program in work space but in this code challenge task it's not accepting. showing bummer Try again.................help asap

trial.py
def add():
      try:
        count1 = float(input("Enter your 1st numbers:  "))
        count2 = float(input("Enter your 2nd numbers:  "))

        except ValueError:
            return None

        else:
             return float(count1) + float(count2)
                #return count1+count2

add()

Maybe include count1 and count2 as the function argument?

def add(count1, count2):

2 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya Prem! You are doing way too many stuff. Just follow the instructions given in the challenges. For the reference , your solution should look like this:

def add(a, b):
    try:
        a = float(a)
        b = float(b)
    except ValueError:
        return None
    return a + b

Hi Prem,

From the instructions it says:

I need you to make a new function, add. add should take two arguments

It looks like you aren't taking in two arguments to your add() function. You want it to look something like this def add(count1, count2) and delete the parts where you are prompting a user for input.