Python Forum

Full Version: How can I add string.upper()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I can't seem to understand how to input tempUnits=tempUnits.upper() so that the user can put upper and lower case F
tempUnits = input("Enter the units of temperature, C for celsius, F for fahrenheit ")

if tempUnits =='F':
    tempUnits=tempUnits.upper()
    temp = float(input("Input the temperature of water in degrees fahrenheit(°F) "))
    temp = (temp - 32) * 5/9
else:
    temp = float(input("Enter the current temperature of the water Celsius(°C) "))

if temp <= 0:
    print("Temperature in celsius must be above zero degrees, or above 32 fahrenheit")
else:
You need to make the change to upper happen before the if statement.
(Oct-11-2020, 06:30 PM)Yoriz Wrote: [ -> ]You need to make the change to upper happen before the if statement.

ah yes that was so simple, thank you!