Lesson 28 of 55
9 mins readPython The table Library: insert, remove, concat & unpack
In Plain English
The standard `table` library provides built-in utilities for array manipulation: `table.insert`, `table.remove`, `table.concat`, `table.pack`, and `table.unpack`.
Deep Dive: How It Works
table.insert(t, [pos,] val): Inserts an element at the end or at a specific 1-based index.
table.remove(t [, pos]): Removes and returns the element at `pos` (defaults to end).
table.concat(t, sep): Joins array strings with a separator.
table.unpack(t): Expands an array into multiple return values.
Core Rules to Remember

table.insert & remove: Standard insertion and removal functions with automatic index shifting.

table.concat(): High-performance string joiner for array elements.
Live Interactive Example
Hit Run Code to see it liveManipulating Arrays with the table Library
Python 3.12
1
2
3
4
5
6
7
8
9
10
Output Console
Click "Run Code" to view the rendered output.
How it works: table.insert placed Beta at index 2, and table.remove popped the last item.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Concatenate Words with table.concat
Declare `local words = { "Fast", "Lightweight", "Embeddable" }`.
Print `"Features: " .. table.concat(words, ", ")`.
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.