C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python String upper() MethodPython upper() method converts all the character to uppercase and returns a uppercase string. Signature
upper() Parameters
No parameters ReturnIt returns a string. Let's see some examples of upper() method to understand it's functionality. Python String upper() Method Example 1
First see a simple example of upper() method. This method returns a uppercase string. # Python upper() method # Declaring table and variables str = "Hello TheDeveloperBlog" # Calling function str2 = str.upper() # Displaying result print(str2) Output: HELLO JAVATPOINT Python String upper() Method Example 2See, how can we use this method in programming. The below example converts all the elements of the list into uppercase. See the example.
# Python upper() method
# Declaring variables
list = ["irfan","sohan","mohan"]
for l in list:
print(l.upper()) # Displaying result
Output: IRFAN SOHAN MOHAN Python String upper() Method Example 3An example that converts all the string into uppercase which starts with vowels. See the example below.
# Python upper() method
# Declaring variables
names = ["irfan","sohan","aman","mohan"]
vowels = ['a','e','i','o','u']
for l in names:
for v in vowels:
if(l.startswith(v)):
print(l.upper()) # Displaying result
Output: IRFAN AMAN
Next TopicPython Strings
|