지출 추가
Coddy Python 여정의 기초 섹션에 포함된 레슨. 77개 중 70번째.
챌린지
쉬움사용자가 지출을 추가하는 옵션(1)을 처리하세요.
- 프로그램 시작 시 빈 expenses 목록을 초기화하세요
- 사용자가 선택지로
1을 선택하면, 사용자에게float형식의 입력을 하나 더 받고 그 값을 expenses 목록에 추가하세요. - 추가한 후 다음을 출력하세요:
Expense added successfully!직접 해보기
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")
while True:
# Get user choice
choice = input()
if choice == "5":
# Exit the program
print("Exiting the Daily Expense Tracker. Goodbye!")
break기초의 모든 레슨
직접 연습해 보세요: 온라인 Python 컴파일러