0
Need help with lesson 14.1 on python working with inputs please.
Somebody wrote code to take two integer inputs and output their product. However, the code results in an error. Fix the code to output the product of two integer inputs. Sample code is print( input()*input() ) sample input is 3 and 6 sample output is 18
2 Réponses
+ 3
input() returns string by default. You can use int() to convert it to an integer.
x = input() -> string
x = int(input()) -> integer
+ 1
You need to use the int() function to use the inputs as integers, otherwise they will be read as strings. Try:
print(int(input()) * int(input()))