Menu
CoddyTech

Recap - Dynamic Input

Part of the Fundamentals section of Coddy's GDScript journey. Lesson 50 of 92.

challenge icon

Challenge

Easy

Write a program that reads a list of whole numbers whose length is given in the input.

The first input line tells you how many numbers follow. Read that many numbers, one per line, and print their sum. The first number is a count, so it is not part of the sum.

For example, for this input:

3
1
5
6

the program prints:

12

because 3 numbers follow, and 1 + 5 + 6 = 12.

Try it yourself

extends Node

func _ready():
	# Read the count, then read and add up that many numbers
	pass

All lessons in Fundamentals

Practice on your own: Online GDScript compiler