Println
Part of the Fundamentals section of Coddy's GO journey — lesson 3 of 109.
Println is a function from the fmt package that prints text followed by a line break. You can print multiple items with a single call.
Print a simple message:
fmt.Println("Learning Go is fun!")When you run this code, you'll see:
Learning Go is fun!Print multiple values separated by commas:
fmt.Println("Go", "is", "awesome")The output shows all items with spaces between them:
Go is awesomeChallenge
BeginnerIn this challenge, you'll practice using fmt.Println() to display multiple values on the same line.
Your task is to use fmt.Println() to print the text Alex 25 coding on a single line.
Remember that fmt.Println() can accept multiple arguments, and it will automatically add spaces between them.
Cheat sheet
Use fmt.Println() to print text followed by a line break:
fmt.Println("Learning Go is fun!")Print multiple values separated by commas (spaces are automatically added between them):
fmt.Println("Go", "is", "awesome")Try it yourself
package main
import "fmt"
func main() {
// TODO: Use fmt.Println() to print "Alex 25 coding" on a single line
// Hint: You can provide multiple arguments to fmt.Println()
fmt.Println(?, ?, ?)
}This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Comparison & Logical Operators
Comparison Operators - Part 1Comparison Operators - Part 2Logical AND OperatorLogical OR OperatorLogical NOT OperatorOperator Precedence BasicsRecap - Making Comparisons7Control Flow: Loops
What The `for` Loop ExplainedFor Loop - BasicFor Loop - Condition OnlyThe `break` KeywordThe `continue` KeywordNested LoopsRecap - Repeating Actions2Variables and Basic Data Types
What is a variableType Inference with `:=`Integers (int)Floating-Point NumbersBooleansStringsZero ValuesConstantsNaming ConventionsRecap - Variables and Types5Basic Input/Output
Formatted OutputFormat VerbsPrinting TypesGetting Basic User InputRecap - Input and Output8Functions
Understanding FunctionsDeclaring a FunctionCalling FunctionsFunction ParametersReturning a Single ValueReturning Multiple ValuesNamed Return ValuesFunction Scope BasicsRecap - Creating Reusable Code3Basic Operators
Arithmetic OperatorsDivision OperatorThe Modulo OperatorAssignment OperatorAugmented Assignment OperatorsIncrement and DecrementRecap - Calculations6Control Flow: Conditionals
The `if` StatementThe `else` KeywordThe `else if` KeywordVariable Shadowing in `if`Initializing VariablesThe `switch` StatementSwitch with ExpressionsSwitch without ExpressionThe `fallthrough` KeywordRecap - Making Decisions