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("Enter Temperature Variable: ")
cOrF = input("Do you want C for celcius, or F for Farehnheit?: ")
if cOrF:
F = 1.8 * uTemp + 32
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
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: "))
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