upper()
upper(): All chars changed to Upper case
All chars are changed to upper case letters , no parameter is taken by this method.
my_str='Welcome to plus2net Python section'
output=my_str.upper()
print(output)
Output
WELCOME TO PLUS2NET PYTHON SECTION
Example 1: Handling Empty String with upper()
my_str = ''
output = my_str.upper()
print(output) # Output: ''
Output:
''
Example 2: Using upper() on String with Mixed Case and Special Characters
my_str = 'Welcome to Plus2Net! @2023'
output = my_str.upper()
print(output) # Output: 'WELCOME TO PLUS2NET! @2023'
Output:
WELCOME TO PLUS2NET! @2023
Use Case: Converting User Input to Upper Case
user_input = input("Enter your name: ")
print(user_input.upper())
Output:
If input is 'john', output: 'JOHN'
« All String methods lower()→ islower() isupper()→
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com