Skip to content
BENIBIX Learn

String Concatenation

Development🧩 Programming ConceptsData and Variables

Also known as Concatenation, Joining Strings, Concat

Joining strings end to end to make one longer string.

Think of it like

It is like joining train cars. Each car hooks onto the end of the one before.

Example

A shop app joins "Order " and the order number to show "Order 1042" on the receipt.

Why it matters

Almost every app builds text for people to read. Messages, names and file paths are often joined from parts.

Definition

String concatenation joins two or more strings into one longer string. Many languages use the + sign to do it. "Hello, " + "Emma" makes "Hello, Emma". The parts are joined exactly, so spaces must be added by hand. Some languages will not join text and a number until you convert the number.

Example code

python
name = "Emma"
print("Hello, " + name)
# Hello, Emma
The + sign joins two strings. The space is inside the first one.
The second card is concatenation. Two strings join into one.

Common mistake

Forgetting the space between the parts. "Hello," + "Emma" gives "Hello,Emma".

Key takeaways

  1. 1
    End to end. Parts are joined in order.
  2. 2
    Exact join. No spaces are added for you.
  3. 3
    Text only. Numbers may need converting first.

Learn it properly