Skip to content
BENIBIX Learn

String

Development🧩 Programming ConceptsData and Variables

Also known as Text String, str

A piece of text in a program. It is written inside quote marks, like "Hello".

Think of it like

Think of it like beads on a thread. Each bead is a letter, and the thread keeps them in order.

Example

A sign-up form keeps the name "Emma Brown" as a string. The site counts 10 characters, space included.

Why it matters

Most of what people type and read is text. Almost every program spends a lot of time with strings.

Definition

A string is a piece of text in a program. It is a row of characters, like letters, digits, spaces and signs. You write it inside quote marks, like "Hello". Programs can join strings, cut them, count their letters or change them to capitals. A name, a message and an address are all usually stored as strings.

Example code

python
>>> name = "Emma" + " " + "Brown"
>>> len(name)
10
>>> name.upper()
'EMMA BROWN'
Three strings joined into one, then counted and turned to capitals.

Common mistake

Forgetting the quote marks. Without them, the computer reads the word as the name of a variable.

Key takeaways

  1. 1
    Text in quotes. Quote marks show where the text starts and ends.
  2. 2
    A row of characters. Each letter, digit or space has a place.
  3. 3
    Many tools. Join, cut, count and change case.

Learn it properly