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!
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
how to check for ValueError for 2 arguments in the block code for try:
i am having trouble in the last task for the challenge where you have to check for valueError in the input values for the arguments.
def add(num1, num2): try: num1= int(input("Give us a numbers: ")) except ValueError: return None else: return float(num1)
Alex KoumparosPython Development Techdegree Student 36,886 Points
In your try block you are asking the user to supply a string. But you don't want any input from the user, you already have the inputs as the arguments to your function:
Thank you. I eliminated the input from the user and it worked.