I wanted to do the following simple calculation by passing values for the parameters num1
and num2
from input()
methods.
I tried following code:
def add(num1, num2):
return num1 * num2
num1 = input('Enter number1: ')
num2 = input('Enter number2: ')
print(add(num1, num2))
But it is showing the following error when it is run (After input num1
and num2
):
TypeError: can't multiply sequence by non-int of type 'str'
Can somebody please explain where did I go wrong and how to convert an input string to the integer type?