Build a function named “multiply” that accepts two user “inputs” when run.
As a user, when I run your function, I should be asked to input the first value I want to multiply, and then the second value.
If any of my inputs are non-numbers (i.e: inputs should be either floats or integers), then the function should return “Error: invalid argument!”
Else, the function should return the product of the two inputs.
def multiply ():
num1 = (input('Multiply '))
num2 = (input ('by '))
if num1 == int:
return "error: invalid error"
else:
print ("int()")
else:
num1 = float(input('Multiply '))
num2 = float(input('by '))
product = (num1*num2)
return product
Aucun commentaire:
Enregistrer un commentaire