Home »
Python »
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?
Submitted by Anuj Singh, on July 11, 2019
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:
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
Practice more python experiences here: python programs
Python Basic Programs »
ADVERTISEMENT
ADVERTISEMENT