Skip to content

Strings

Strings can be represented using single or double quotes:

str1 = "Hello World"
str2 = 'Hello World'

Concatenation

There are multiple ways to concatenate two string:

str1 = "Hello"
str2 = "World"

String Concatenation

both = str1 + " " + str2
print(both)
Hello World

Format Concatenation

both = "{0} {1}".format(str1, str2)
print(both)
Hello World

f-string

both = f"{str1} {str2}"
print(both)
Hello World