Menu
Coddy logo textTech

Printing Literals

Part of the Fundamentals section of Coddy's Lua journey — lesson 26 of 90.

let's revisit the print() function to focus on outputting literal values directly. Literal values are fixed pieces of data that you write directly in your code, like specific numbers or text strings.

You can print numbers directly by passing them to the print() function:

print(100)    -- Prints: 100
print(42.5)   -- Prints: 42.5

Similarly, you can print string literals by enclosing text in quotes:

print("Welcome!")     -- Prints: Welcome!
print('Game Over')    -- Prints: Game Over
challenge icon

Challenge

Easy

Display a game's welcome message and starting score using literal values. Print the string "Welcome to Adventure Quest!" on the first line, then print the number 0 on the second line to show the player's starting score.

Cheat sheet

You can print literal values directly using the print() function.

Print numbers:

print(100)    -- Prints: 100
print(42.5)   -- Prints: 42.5

Print strings using quotes:

print("Welcome!")     -- Prints: Welcome!
print('Game Over')    -- Prints: Game Over

Try it yourself

-- TODO: Write your code here
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals