October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk1 min

How to Convert a String to Uppercase in Python

Use Python’s built-in str.upper() method to return an uppercase version of a string, and assign the result if you need to keep it.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call Python’s built-in upper() method: text.upper(). It returns a new string with cased characters converted to uppercase; assign that result if you want to keep it.

Use str.upper() to convert a string

Call upper() on the string, then use or print the returned value:

text = "Hello, Python!"
uppercase_text = text.upper()
print(uppercase_text)  # HELLO, PYTHON!

upper() is a built-in string method, so you do not need an import or an external package. Python’s documentation describes it as returning a copy of the string with its cased characters converted to uppercase: Built-in Types — Python 3.14.8 documentation.

Keep the uppercase result

Strings are not changed in place by upper(). The method returns a new string, so assign the result to a variable if you need to retain it. To replace the value stored under the original variable name, write:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
text = text.upper()

Use casefold() for matching, not uppercase display

upper() is the appropriate choice when you want uppercase text to display. For caseless text matching, Python provides casefold(), which is a more aggressive conversion intended for that purpose; it is not a substitute for producing uppercase output. See the Python string-method documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Unicode characters and isupper()

Python strings support Unicode, and the documentation says the uppercasing algorithm is described in section 3.13 of the Unicode Standard. Casing behavior therefore applies to Unicode characters, not just the English alphabet.

Do not treat result.isupper() as a universal check that every character in a string is uppercase. Python documents that s.upper().isupper() can still be false when the result contains uncased characters or characters in the titlecase category. The documentation for upper() and isupper() explains this caveat.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.