Skip to content Skip to sidebar Skip to footer

Typeerror: Can't Multiply Sequence By Non-int Of Type 'float' Python 2.7

Hi I'm a 11 year old who has taken up python as a hobby. I'm trying to make a mass converter as a first project. But for some reason I've been getting this error: TypeError: can't

Solution 1:

raw_input returns a string, you're basically doing this:

print"1234" * 2.20462

You need to convert the input to a number:

kilo = float(raw_input())
pounds = 2.20462

print kilo * pounds

 

The error message is somewhat confusing because you can multiply a string (or any sequence) by an integer:

print"abc" * 3   # prints "abcabcabc"

Post a Comment for "Typeerror: Can't Multiply Sequence By Non-int Of Type 'float' Python 2.7"