The .upper()
method in Python is used to convert a string to uppercase.
Syntax:
string.upper()
Example Usage:
text = "hello world"
upper_text = text.upper()
print(upper_text) # Output: HELLO WORLD
Calling upper()
on a variable:
name = "Python"
print(name.upper()) # Output: PYTHON
Calling upper()
directly on a string literal:
print("hello".upper()) # Output: HELLO
Would you like more details on how it works?
Leave a Reply