Python Programming Exercises, Gently Explained
105
version of that letter. Otherwise, a non-lowercase letter character can be copied to the new string as-
is.
After the loop finishes, getUppercase() returns the newly-built uppercase string.
Getting the uppercase version of a letter will involve a dictionary that maps lowercase letters to
uppercase letters. If a character from the text parameter exists as a key in the dictionary, we know it
is a letter and the dictionary contains its corresponding uppercase version.
This uppercase letter is
concatenated to the end of the returned string. Otherwise, the original character from text is
concatenated to the returned string.
Dostları ilə paylaş: