TypeError: Can't Multiply Sequence By Non-int Of Type 'float' 3.3
Ok I have edited the code to where it would hopefully work but I get the TypeError: can't multiply sequence by non-int of type 'float'. Heres the code that I have: uTemp = input('E
Solution 1:
The error is telling you that you can't multiply uTemp
, a string, by a floating-point number (1.8
). Which makes perfect sense, right? What is eight tenths of a string? Convert uTemp
to a float:
uTemp = float(input("Enter Temperature Variable: "))
Your next problem is that cOrF
is treated as a Boolean (true/false) value, which means F
will be calculated if the user enters anything at that prompt since all non-empty strings are truthy in Python. So instead you would write:
if cOrF == "F":
F = 1.8 * uTemp + 32
Solution 2:
input()
returns a string in python 3.x.
Convert it to float
(or to int
- depends on your needs):
uTemp = float(input("Enter Temperature Variable: "))
Post a Comment for "TypeError: Can't Multiply Sequence By Non-int Of Type 'float' 3.3"