I don't know how to multiply in Python.
If I do this:
price = 1 * 9
It will appear like this:
111111111
And the answer needs to be 9
(1x9=9
)
How can I make it multiply correctly?
Only when you multiply integer with a string, you will get repetitive string..
You can use int()
factory method to create integer out of string form of integer..
>>> int('1') * int('9')
9
>>>
>>> '1' * 9
'111111111'
>>>
>>> 1 * 9
9
>>>
>>> 1 * '9'
'9'
Should work:
In [1]: price = 1*9
In [2]: price
Out[2]: 9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With