Python Practice › Loop Programs › Program 8

Convert uppercase letters to lowercase

EasyLoop Programs · 8 of 90

Write a Python program that converts all uppercase letters in a word to lowercase, using a loop.

Advertisement
Input
"SqaTOOlS"
Output
sqatools

Approach

  1. Loop over the characters, lower-case the uppercase ones and build a new string.

Solution

Python
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.

More loop programs

← All 90 Loop Programs

Leave a Comment