uppercase to lowercase in python

Description

python program to get a String and convert the upper case characters tolower case Characters
Input:
Hello
Output:
hello

Solution

s=input("Enter a String:")
result=""
for i in range(0,len(s)):
    ascii_val = ord(s[i])
    if(ascii_val>64 and ascii_val<91):
        result+=chr(ascii_val+32)
    else:
        result+=chr(ascii_val)
s=result
print(s)

Explanation

unicode / ascii_val of lower case alphabets are from 97 to 122
unicode / ascii_val of upper case alphabets are from 65 to 90
so the difference between lower case and uppercase alphabets is 32.

use ord() method to find ascii_val of a character.

Use chr() method to find character of ascii value
Note:
String is immutable, so you cannot modify a character directly in a orginal string.



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution