Menu
CoddyTech

Exit The Program

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

challenge icon

Challenge

Easy

Now the program waits for the choices of the user. Keep the welcome message and the menu, and add after them:

  1. An infinite loop: while true:
  2. In each iteration, read one line of input, the choice (1 to 5 from the menu), and keep it as text
  3. If the choice is "5", print the line below and leave the loop with break
Exiting the Daily Expense Tracker. Goodbye!

For now, ignore every other choice: the loop reads the next line. Every test ends with the choice 5.

Try it yourself

extends Node

func _ready():
	print("Welcome to the Daily Expense Tracker!")

	# Display the menu once
	print("\nMenu:")
	print("1. Add a new expense")
	print("2. View all expenses")
	print("3. Calculate total and average expense")
	print("4. Clear all expenses")
	print("5. Exit")

All lessons in Fundamentals

Practice on your own: Online GDScript compiler