Python Convert String Lowercase to Uppercase

Python convert lowercase string (all letters) to uppercase; Through this tutorial, i am going to show you how to convert lowercase string to uppercase in python with and without using function.

How to Convert Lowercase String to Uppercase in Python

There are two way to convert lowercase string to uppercase in python with and without using string function:

  • 1: Convert lowercase to uppercase in python with using the function
  • 2: How to convert lowercase to uppercase in python without using string function

1: Convert lowercase to uppercase in python with using the function

The python string upper() method converts all letters or characters of string lowercase to uppercase.

The syntax of python string upper() method is:

string.upper()

String upper() Parameters()

The upper() method doesn’t take any parameters.

Return value from String upper()

The upper() method returns the uppercased string from the given string. It converts all lowecase characters to uppercase.

If no lowercase characters exist, it returns the original string.

Example 1: write a program to convert all lowercase to uppercase characters in python

See the python program to convert all string character lowercase to uppercase characters in python:

# example string
string = "This is first example of convert string lowercase to uppercase"
print(string.upper())
#Output
#THIS IS FIRST EXAMPLE OF CONVERT STRING LOWERCASE TO UPPERCASE

2: How to convert lowercase to uppercase in python without using string function

Write a program in Python that will convert all the letters or characters of the string from lowercase to uppercase without using any Python function:

# convert lowercase to uppercase in python without using function
st = 'how to convert lowercase to uppercase in python without using string function'
out = ''
for n in st:
    if n not in 'abcdefghijklmnopqrstuvwqxyz':
        out = out + n
    else:
        k = ord(n)
        l = k - 32
        out = out + chr(l)
print('------->', out)   

The output of above python program is:

HOW TO CONVERT LOWERCASE TO UPPERCASE IN PYTHON WITHOUT USING STRING FUNCTION

Recommended Python Tutorials

Recommended:-Python Modules
Recommended:-Python Lists
Recommended:-Python Strings

One Comment

  1. Abhijeet Deshmukh said:

    It was good to learn from this website, But it would have been great if you have provided a video for better understanding of the concept….

    August 11, 2021
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *