+ 1
Is this code correct?
x = input() y = input() print(x*y)
5 Answers
+ 8
no, you'd need to change the input to integers.
x = int(input())
...
+ 3
.... addition to all others: at least one of x and y should be converted. And .... integer is just one opportunity
+ 1
Thanks
0
It's not correct because input() returns string and it doesn't make sense to multiply to strings. By the way it will work if:
1- both x and y are converted to float OR integer like this:
x = int(input())
y = float(input())
print(x * y)
Inputs: 2, 3
Output: 6.0
2- x OR y is converted to float OR integer and the other remains string. This way the string will be repeated by the integer OR float.
x = str(input())
y = int(input())
print(x * y)
Inputs: 2, 3
Output: 222