Python Practice › Loop Programs › Program 8
Convert uppercase letters to lowercase
Write a Python program that converts all uppercase letters in a word to lowercase, using a loop.
Input
"SqaTOOlS"
Output
sqatools
Approach
- Loop over the characters, lower-case the uppercase ones and build a new string.
Solution
word = "SqaTOOlS"result = ""for ch in word: if ch.isupper(): result += ch.lower() else: result += chprint(result)Output
sqatools
Line by line
Lines 4-5
Only uppercase characters are changed.
Tip
word.lower() does the whole job in one call; the loop shows how it works.
Learn the concept
New to this topic? Read the lesson, then come back.