## Sunday, October 18, 2020

Solution Exercise 53 : python code to transform given a string into lowercase #### Exercise 53

Using Exercise 51, create a python program as a function which takes as a parameter a string s and which returns the same string in lowercase without using the lower() method. You can use the chr() and ord() methods.

#### Solution

``````def toLowercase(s):
# by using the exercise 51 we can obtain the lists of all upercase characters and lowercase characters:
uppercase_characters = [chr(i) for i in range(65 , 91)]
lowercase_characters =  [chr(i) for i in range(97 , 122)]
# then we can obtain a lowercase characters from uppercase characters by adding 32 to its ascii code

# initializing the searched string
s_lower = ""
for x in s:
if x in uppercase_characters:
x = chr(ord(x) + 32)
s_lower = s_lower + x
else :
s_lower = s_lower + x

return s_lower
print(toLowercase("PYTHON COURSES"))
# The output is : python courses``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 