In this tutorial, We will see the python string upper() method with examples.
upper() Method
The upper() method is one of the methods in a python string. The upper() method is used for string conversion.
The upper() method converts the string into uppercase.
- The upper() method converts lowercase characters to uppercase characters.
- If the character is in the already upper case then applying the upper method will not bring any change.
Syntax of Python string upper() method
This is the syntax of the python string upper() method.
string.upper()
Example of Python string upper() method
#Example 1 text = "Python is a programming language" #Convert text into uppercase character. print(text.upper()) #output : PYTHON IS A PROGRAMMING LANGUAGE
#Example 2 text = "Convert into uppercase, python upper method" print(text.upper()) #output: CONVERT INTO UPPERCASE, PYTHON UPPER METHOD #Exmaple 3 message = "Hello world!" msg = message.upper() print(msg) #output: HELLO WORLD!
Program: Take a string from user input and convert it into uppercase.
message = input("Enter the message") msg = message.upper() print(msg)
Related Posts