Output
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 31 of 92.
A program shows its results as output. Writing output is often called printing. In GDScript, print() writes one line of text to the output:
print("Hello")The text goes inside quotation marks. Double quotes and single quotes both work, so these two lines print the same thing:
print("Game Over")
print('Game Over')Every print() ends its line, so the next print() starts on a new one. A print() with nothing inside prints an empty line:
print("Level 1")
print()
print("Level 2")This prints Level 1, an empty line, then Level 2.
Text without quotation marks is read as code: print(Hello) looks for a variable named Hello, and GDScript reports an error because there is none.
Challenge
BeginnerWrite a program that prints these two lines:
I love GDScript
Let's make games!Use one print() for each line, and replace the line pass with your code.
Try it yourself
extends Node
func _ready():
# Print the two lines here
pass
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler