-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
144 lines (101 loc) · 3.86 KB
/
main.py
File metadata and controls
144 lines (101 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# # Expense Tracker Project
# expensesList = [] #list of all expenses
# print(" Welcome to Expense Tracker : ")
# while True:
# print("====MENU====📑")
# print("1. Add Expense")
# print("2. View All Expenses")
# print("3. View Total Expenses")
# print("4. Exit")
# choice = int(input("Please Enter Your Choice : "))
# # 1. ADD EXPENSE
# if(choice == 1):
# date = input("In which date you made an expense?: ")
# category = input("Enter Category? (Food, Travel, Makeup, Books): ")
# description= input("Add more detail to it: ")
# amount = float(input("Enter the amount: "))
# expense = {
# "date": date,
# "category": category,
# "description": description,
# "amount": amount
# }
# expensesList.append(expense)
# print(" \nDONE. Expense is added successfully")
# # 2. VIEW ALL EXPENSES
# elif(choice == 2):
# if(len(expensesList) == 0):
# print("No Expenses Added. First make some expenses")
# else:
# print("==== List of all expenses💸💲 ====")
# count = 1
# for eachitem in expensesList:
# print(f"Expense Number{count} -> {eachitem["date"]}, {eachitem["category"]}, {eachitem["description"]}, {eachitem["amount"]}")
# count = count + 1
# # 3. VIEW TOTAL SPENDING
# elif(choice == 3):
# total = 0
# for eachitem in expensesList:
# total = total + eachitem["amount"]
# print("\n Total Expenses📲 = ", total)
# # 4. EXIT
# elif(choice == 4):
# print("Thank You for using our system 💻")
# break
# else:
# print("Invalid Choice🚫. Try Again ")
# EXPENSE TRACKER
# You are required to build a simple personal finance management tool.
# The program should allow the user to:
# ● Add an expense with details like date, category, description, and amount.
# ● View all recorded expenses in a clean format.
# ● Calculate total spending so far.
# ● Exit the program gracefully when the user chooses to.
# All tasks must be implemented using loops, if-else, lists, and dictionaries
# only. No user-defined functions or file handling should be used.
# Expense Tracker Project
expensesList = [] #List of all expenses
print(" Welcome to Expenses Tracker: ")
while True:
print("====MENU====")
print("1. Add Expense")
print("2. View All Expenses")
print("3. View Total Expenses")
print("4. Exit")
choice = int(input("Please Enter Your Choice : "))
# 1. ADD EXPENSE
if(choice == 1):
date = input("In which date you made an expense?: ")
category = input("Enter Category? (Food, Travel, Makeup, Books): ")
description = input("Enter more detail to it: ")
amount = float(input("Enter the amount: "))
expense = {
"date": date,
"category": category,
"description": description,
"amount": amount
}
expensesList.append(expense)
print(" \nDONE BRO. Expense is added successfuly")
# 2. VIEW ALL EXPENSES
elif(choice == 2):
if(len(expensesList) == 0):
print("No Expenses Added. First make some expenses")
else:
print("==== List of all Expenses ====")
count = 1
for eachitem in expensesList:
print(f"Expense Number{count} -> {eachitem["date"]}, {eachitem["category"]}")
count = count + 1
# 3. VIEW TOTAL SPENDING
elif(choice == 3):
total = 0
for eachitem in expensesList:
total = total + eachitem["amount"]
print("\n Total Expenses = ", total)
# 4. EXIT
elif(choice == 4):
print("Thank you for using our system")
break
else:
print("Invalid Choice. Try again")