Python Forum
How can I add string.upper()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I add string.upper()
#1
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:
Reply
#2
You need to make the change to upper happen before the if statement.
Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace with upper(string) WJSwan 7 1,587 Feb-10-2023, 10:28 AM
Last Post: WJSwan
  AttributeError: 'list' object has no attribute 'upper' Anldra12 4 4,895 Apr-27-2022, 09:27 AM
Last Post: Anldra12
  Upper-Bound Exclusive Meaning Johnny1998 1 3,358 Aug-02-2019, 08:32 PM
Last Post: ichabod801
  How to only extract upper or lower triangular matrix into tabular form SriRajesh 3 25,680 Jan-04-2019, 01:21 AM
Last Post: scidam
  change only one element of list to upper case python1980 3 11,734 Dec-03-2017, 07:23 PM
Last Post: python1980

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020