10 Telephone: Randomly mutating strings

“What we have here is a failure to communicate.”


Now that we’ve played with randomness, let’s apply the idea to randomly mutating a string. This is interesting, because strings are actually immutable in Python. We’ll have to figure out a way around that.

To explore these ideas, we’ll write a version of the game of Telephone where a secret message is whispered through a line or circle of people. Each time the message is transmitted, it’s usually changed in some unpredictable way. The last person to receive the message will say it out loud to compare it to the original message. Often the results are nonsensical and possibly comical.

We will write a program called telephone.py that will ...

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.