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 trialNagamani Krishnakumar
425 Pointshow 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)
2 Answers
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Nagamani,
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: num1
and num2
.
Nagamani Krishnakumar
425 PointsThank you. I eliminated the input from the user and it worked.