We've already gone over how to use multiplication in Python, but did you know that Python can be used to multiply things other than numbers? In fact, you can use Python to multiply strings, which is actually pretty cool when you think about it. You can take a string and double, triple, even quadruple it with only a little bit of Python.

There are a few different ways that we can go about multiplying strings, depending on how you want your multiplied strings to be formatted. Take a look at the code snippets below to see how it works:

To simply multiply a string, this is the most straightforward way to go about doing it:

2*'string'

The output for the code above would be:

stringstring

This works, obviously, but it's not perfect if you don't want your multiplied string to read as one large, giant string. If you want your strings to be separated and not just read as one long word, you'll have to change the code up a bit, and change your string to a tuple, like this:

4*('string',)

The output for the code above would be:

('string', 'string', 'string', 'string')

Much more legible.

You can also use Python to multiply sets of words, strings, or tuples. Check out the code snippet below to see how it's done:

3*('good', 'morning')

The output for the code above would look like this:

('good', 'morning', 'good', 'morning', 'good', 'morning)

As you're probably starting to see, using Python to multiply strings isn't complicated at all. It's pretty cool that you can use the same concept you'd use to multiply numbers (our handy * symbol) to multiply words and other types of objects. Sadly, this same concept doesn't really work with division the same way it does with multiplication, but you can do something similar with addition -- but that's for another tutorial!

To Practice: Try this interactive course on the basics of Lists, Functions, Packages and NumPy in Python.