Menu
Coddy logo textTech

Recap - Repeating Actions

Part of the Fundamentals section of Coddy's GO journey. Lesson 50 of 109.

challenge icon

Challenge

Easy

Complete the code to implement different types of loops and print the results.

The exact text is Sum: 15.

Try it yourself

package main

import "fmt"

func main() {
  // TODO: Write a for loop that prints numbers from 1 to 5
  // Each number should be on its own line
  
  // TODO: Print a blank line for separation
  
  // TODO: Write a for loop that calculates the sum of numbers from 1 to 5
  // Store the result in a variable named 'sum'
  // After the loop, print the exact text from the instructions
  
  // TODO: Print a blank line for separation
  
  // TODO: Write a for loop that starts at 10 and counts down to 1
  // Each number should be on its own line
}

All lessons in Fundamentals

Practice on your own: Online Go compiler