Python String upper Method - Python Tutorial | Logic Practice
Python Course / Other / Python String upper Method

Python String upper Method

BLUF: This lesson on Python String upper Method provides a comprehensive guide to understanding and implementing this concept in Python. Whether you're a beginner or looking to refresh your knowledge, you'll find clear explanations and interactive code examples here.
Key Concept: Python String upper Method

Mastering Python String upper Method is essential for building efficient Python applications. Focus on the syntax and the best practices highlighted in this tutorial.

The Python upper method transforms all characters in a string to uppercase and returns the modified string in uppercase format.

Signature

Example

upper()

Parameters

No parameters

Return

It returns a string.

Let us examine a few examples of the upper method to grasp its functionality.

Python String upper Method Example 1

To begin, let's examine a straightforward illustration of the upper method. This particular method yields a string where all characters have been converted to uppercase.

Example

# Python upper() method
# Declaring table and variables
str = "Hello logicpractice"
# Calling function
str2 = str.upper()
# Displaying result
print(str2)

Output:

Output

HELLO LOGICPRACTICE

Python String upper Method Example 2

Let's explore how we can implement this technique in programming. The following example demonstrates the conversion of every element within the list to uppercase. Observe the example provided.

Example

# Python upper() method
# Declaring variables
list = ["irfan","sohan","mohan"]
for  l in list:
    print(l.upper()) # Displaying result

Output:

Output

IRFAN
SOHAN
MOHAN

Python String upper Method Example 3

Here is an illustration that transforms every string that begins with a vowel into uppercase. Refer to the example provided below.

Example

# 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:

Output

IRFAN
AMAN

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience