Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Python by (50.2k points)

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)

The above code is giving an error, what to do?

1 Answer

0 votes
by (108k points)

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+b

num1 = int(input("Enter first number: "))

num2 = int(input("Enter second number: "))

res = solveMeFirst(num1,num2)

print(res)

 Interested in learning Python? Enroll in our Python Certification course now!

Related questions

Browse Categories

...