Back
I want to add two numbers and I want to take user-defined input, how can I take that:
def solveMeFirst(a,b): return a+b num1 = int(input(2)) num2 = int(input(3)) res = solveMeFirst(num1,num2) print(res)
def solveMeFirst(a,b):
return a+b
num1 = int(input(2))
num2 = int(input(3))
res = solveMeFirst(num1,num2)
print(res)
The above code is giving an error, what to do?
The main problem is with the input(). Your format is wrong, kindly refer to the below code that will takes user input.
def solveMeFirst(a,b): return a+bnum1 = int(input("Enter first number: "))num2 = int(input("Enter second number: "))res = solveMeFirst(num1,num2)print(res)
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
Interested in learning Python? Enroll in our Python Certification course now!
31k questions
32.8k answers
501 comments
693 users