.upper()
rhysfirkins1 total contribution
Published Sep 6, 2023
Contribute to Docs
The .upper()
function converts a string to uppercase.
Syntax
string.upper(string)
The .upper()
function will convert all letters of a specified string to uppercase. Numbers and punctuation will remain unaffected.
Example
The example below shows how .upper()
takes a string with both upper and lower case letters and returns it in uppercase.
Note: The
.upper()
function creates a copy of the specified string to modify, leaving the original unchanged.
myString = "Bang!"print(myString)print(string.upper(myString))print(myString)
This code will display the following output:
Bang!BANG!Bang!
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.