Python - Strings



In python, you can create a string by surrounding your text in a quotes.

myString = 'Hello World'
myString2 = "Hello, World"
myString3 = '''Hello World'''
myString4 = """Hello world"""

We can see that we have quite a few options here:

  • ' single quote

  • " double quote

  • ''' three single quotes

  • """ three double quotes

The main reason for double quotes, is that you can use them to have multiple lines.

myMultiString = """
This is a multiline comment
Some more stuff goes here

Using the str()

Another way to create string is to use the string function. Here are some quick examples:


the str() function will convert values into string. There is much more we can do with the string funciton though, but we will save that for later.