Skip to main content

Strings

What is a string?

A string is a sequence of characters. In programming, strings are often used to represent text.

Defining Strings

Strings are defined using quotation marks. For example, the following code defines a string named animal and sets it to the value "cat":

animal = "cat"

Combining strings with a number

Whenever you add a string to a number (or vice versa), the end result will be a string. The numbers are implicitly converted into strings. For example, the following code will print the string "123abc":

"123" + "abc"