Wednesday, February 1, 2017

Lower Function User Defined Python

Tags

Following code will define a lower function to convert all letters of a string to lower case:

Code::

def lower(a):
    x=""
    for i in a:
        if(i>='A' and i<'a'):
            x=x+((chr((ord(i)+32))))     #ord to convert character to ascii value
        else:
            x=x+i
    return x

i=input("Enter any String :")
print(lower(i))

Output::