0
How do you return a value that is inputted
def multiply(x, y): return x * y a = input() b = input() operation = multiply print(operation(a, b)) this code gives me an error
5 ответов
+ 4
If you want to do it step by step, you can assign:
a = input()
b = input()
a = int(a)
b = int(b)
but it's more convenient to write:
a = int(input ())
b = int(input ())
or (the cleanest option) leave the variables as they are and force the type only in the method definition, like VEdward did.
+ 3
because the input is string... you need to convert them to integer then multiply...
you can't multiply strings
use this..
return int(a)*int(b)
+ 1
how do you do that?
int = a
int = b
??
+ 1
a=int (input ())
b=int (input ())
+ 1
thank you for you guys' help. i really appreciate this.