Lesson 05 of 55
9 mins readPython Strings, Concatenation (..) & Length (#)
In Plain English
Lua strings are immutable sequences of bytes. Combine strings using the two-dot concatenation operator (`..`), measure length with `#str`, and declare multi-line text with long brackets `[[ ... ]]`.
Deep Dive: How It Works
Concatenation (..): Joins strings: `"Hello " .. "World"` produces `"Hello World"`.
Length Operator (#): Returns byte length: `#("Lua")` is 3.
Long Brackets ([[ ... ]]): Multi-line raw strings that ignore escape characters.
Immutability: Modifying a string creates a new string interned in memory.
Core Rules to Remember

Two Dots (..) for Concatenation: Never use `+` to join strings in Lua; always use `..`.

Hash (#) for Length: `#string` returns string byte length.
Live Interactive Example
Hit Run Code to see it liveString Operations and Long Brackets
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
Output Console
Click "Run Code" to view the rendered output.
How it works: .. concatenated the greeting, # measured length, and [[ ]] preserved multi-line formatting.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Concatenate and Measure Length
Declare `local prefix = "Zen"` and `local name = prefix .. "Compiler"`.
Print `"Name: " .. name .. " Length: " .. #name`.
1
2
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.