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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.