Exit The Program
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 84 of 92.
Challenge
EasyNow the program waits for the choices of the user. Keep the welcome message and the menu, and add after them:
- An infinite loop:
while true: - In each iteration, read one line of input, the choice (
1to5from the menu), and keep it as text - If the choice is
"5", print the line below and leave the loop withbreak
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
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values13Iterating Over Arrays
Iterating Over ElementsIterating With IndexesIterating Over Strings Part 1Iterating Over Strings Part 216Daily Expense Tracker
Project OverviewExit The Program5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler