I realise that this is probably simple and basic to you guys, its for my childs homework and I don't have any experience or idea on the use of Python. She needs to get the code to request a number, multiply it by 9 and show the result. She is using the code below, however it repeats the number rather than multiply it. (ie it show 3 * 9 as 999 instead of 27). From what I have read it appears this is something to with multiplying integer by strings (though I may be wrong). Any help would be greatly appreciated.
number=input("Enter a number to multiply by 9 ")
number=number*9
print('the answer is '+number)
Wrap your input
in either int
or float
number=int(input("Enter a number to multiply by 9 "))
or
number=float(input("Enter a number to multiply by 9 "))
This is done because input
accepts strings and you have to convert these to numerals.
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