upper() and lower()

noun

say it: “UP-er and LOH-er” /ˈʌpər ænd ˈloʊɚ/

Python's string methods that give a copy of the text in all capital letters or all small letters, so text typed in different ways can be compared.

What do upper() and lower() do?

upper() gives an ALL CAPS copy of a string and lower() an all lowercase copy. Handy for comparing text without worrying about capitals.

answer = "Yes"
if answer.lower() == "yes":
    print("Confirmed")
print("sale".upper())  # SALE

In a sentence

  • “After lower(), "MARIA" and "Maria" were the same name.”
  • “The signs needed every flavor in capitals, so she used upper() on the column.”

Level: Apprentice · More Python terms at this level

Updated