.upper()
gracekishino26 total contributions
Published Jun 8, 2021Updated Jan 7, 2023
Contribute to Docs
The .upper()
method takes a string and returns a copy of that string in which all letters are uppercase. Numbers and symbols are not changed.
Note: The
.upper()
method does not change the string it is used on.
Syntax
string.upper()
Example
The following example shows how .upper()
returns a string with all its letters in uppercase. It also shows that the original string remains unchanged:
my_string = "shout"print(my_string)print(my_string.upper())print(my_string)
This would output:
shoutSHOUTshout
Codebyte Example
The following example shows how the .upper()
method can be used to compare strings:
All contributors
- gracekishino26 total contributions
- Anonymous contributorAnonymous contributor15 total contributions
- christian.dinh2481 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions
- CyberRedPanda27 total contributions
- gracekishino
- Anonymous contributor
- christian.dinh
- Anonymous contributor
- CyberRedPanda
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.