12 Ransom: Randomly capitalizing text

All this hard work writing code is getting on my nerves. I’m ready to turn to a life of crime! I’ve kidnapped (cat-napped?) the neighbor’s cat, and I want to send them a ransom note. In the good old days, I’d cut letters from magazines and paste them onto a piece of paper to spell out my demands. That sounds like too much work. Instead, I’m going to write a Python program called ransom.py that will encode text into randomly capitalized letters:

$ ./ransom.py 'give us 2 million dollars or the cat gets it!'
gIVe US 2 milLION DoLlArs or ThE cAt GEts It!

As you can see, my diabolical program accepts ...

Get Tiny Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.