プログラムの終了
CoddyのPythonジャーニー「基礎」セクションの一部。レッスン 69/77。
チャレンジ
簡単それでは、実際のプログラムを作成しましょう!
- ループの前に、ウェルカムメッセージとメニューを1回表示します(ループ内では繰り返されません)
- 無限のwhileループを作成します(方法がわからない場合はヒントを参照してください)
- ループの各反復で、ユーザーから入力を受け取ります。これは選択肢(メニューの1~5)になります
- 最初のケースを処理します。選択肢が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")基礎のすべてのレッスン
自分で練習してみよう: Pythonオンラインコンパイラ