I recently started my master degree in data science with emphasis on machine learning, in order to training on my python skills I’m solving Leetcode challenges.
In problem 709 we’re asking to replace every uppercase letter with the same lowercase letter.
Basically, there’s two different ways to resolve this issue:
Using The ‘Lower’ Method (the easiest solution)
By using .lower we can convert every uppercase letter into lowercase:
|
|
Converting letters by using ASCII
We need to create a for loop that checks whether a capital letter exists and replaces it by applying an offset from the ASCII table. (For example, subtracting 32 from the ASCII value would convert it to lowercase):
|
|