プログラムの終了
CoddyのPythonジャーニー「Fundamentals」セクションの一部 — レッスン 69/77。
チャレンジ
簡単それでは、実際のプログラムを作成しましょう!
- 無限の while ループを作成します(方法がわからない場合はヒントを参照してください)。
- ループの各反復で、ユーザーから入力を取得します。これがメニューの choice(1 - 5)になります。
- 最初のケースを処理します。もし choice が "5" と等しい場合は、プログラム(ループ)を終了し、次のように出力してください:
Exiting the Daily Expense Tracker. Goodbye!自分で試してみよう
print("Welcome to the Daily Expense Tracker!")
# Display 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")