Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 751 Bytes

File metadata and controls

32 lines (21 loc) · 751 Bytes

Unit 2 Practice Solutions

Exercise 3 - Flip Letter Casing

Solution

# ask the user for some text
text = input('Please enter a word or phrase: ')

# use the .swapcase() string method to swap uppercase with lowercase and vice versa
print(text.swapcase())

Output

Enter a word or phrase: HeLlO wOrLd
hElLo WoRlD

------------------------------------------
Enter a word or phrase: UPPER lower
upper LOWER

------------------------------------------
Enter a word or phrase: supERCaliFRagIliSticEXpiAliDoCIOus
SUPercALIfrAGiLIsTICexPIaLIdOcioUS

Keep in mind that this is just one potential solution.