Topic 5 String Formatting and a Pythonic Equivalent of a switch-case Statement

A Giant Mess of Strings

Figure 5.1: A Giant Mess of Strings

You probably already know what a string is in Python: an array of sequenced characters enclosed in single, double, or even triple quotes. Furthermore, you may have also seen prof. Marek or Mu perform string concatenation like so:

sentence = "My name" + " is " + "Kevin!"

And while this works, what if I told you that this isn’t the only way to format strings? In fact, there are three more ways to do the same thing (at least to my knowledge)!

When you’re ready, go to the next subsection of the webpage!