×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to lowercase the character without using a function

Lowercase the character: Here, we are going to learn how to lowercase the character without using a function in Python? By Anuj Singh Last updated : January 04, 2024

Problem statement

In this article, we will go for de-capitalizing the characters i.e. conversion from lowercase to uppercase without using any function. This article is based on the concept that how inbuilt function performs this task for us.

Writing code to take user input as a string and then de-capitalize every letter present in the string.

So, let's write a program to perform this task.

Key: The difference between the ASCII value of A and a is 32

Example

Consider the below example with sample input and output:

Input:
Hello world!

Output:
hello world!

Python code to lowercase the character without using a function

# Python program to lowercase the character 
# without using a function
st = input('Type a string: ')
out = ''
for n in st:
    if n not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        out = out + n
    else:
        k = ord(n)
        l = k + 32
        out = out + chr(l)
print('----->', out)    

Output

First run:
Type a string: Hello world!
-----> hello world!

Second run:
Type a string: HHJHJHFF$%*@#$
-----> hhjhjhff$%*@#$

Third run:
Type a string: abcds14524425way
-----> abcds14524425way

To understand the above program, you should have the basic knowledge of the following Python topics:

Practice more python experiences here: python programs

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.