Learn Lua from your first print to a small project, with tables, functions and string patterns along the way.
8 lessons, 16 exercises. Runs Lua 5.5.
Not started
Hello, output
Print text with print and io.write, add comments, and see how Lua runs a script from top to bottom.
Values and variables
Store data in local variables, meet Lua's basic types, and mark constants with the <const> attribute.
Reading input and arithmetic
Read numbers and lines from standard input with io.read, convert text with tonumber, and use Lua's arithmetic operators.
Making decisions
Choose between paths with if, elseif and else, using comparison operators, and/or/not, and Lua's rules for truth.
Loops
Repeat work with numeric for loops, while and repeat-until loops, and leave a loop early with break.
Functions
Define local functions with parameters and return values, return several values at once, and understand local scope.
Tables
Use Lua's one data structure, the table, as both a list and a dictionary, and walk through it with ipairs and pairs.
Strings and a small project
Use the string library and Lua patterns to slice, search and transform text, then build a small grade report program.
Your progress is saved in this browser. Sign in to keep it on every device.