-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminiproject expense tracker.py
More file actions
62 lines (48 loc) · 1.84 KB
/
Copy pathminiproject expense tracker.py
File metadata and controls
62 lines (48 loc) · 1.84 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
# create a console based expense tracker program in python that allows the user to record daily expenses
# and view summaries like total spending . use loops , conditions, lists, dictionaries, and basic input/output
Expenselist=[] # list of expenses in form of dictionaries.
print("welcome to expense tracker om : kharcha kro")
while True:
print("======menu======")
print("1. Add expenses")
print("2. view all expenses details")
print("3. view total expenditure")
print("4. thank you ")
choice=int(input("enter your choice"))
# add expenses
if (choice==1):
date=input("date of expenditure")
category=input("type of expenditure like food, travel, shoping")
description=input("more deatils about expenditure")
amount=int(input("enter the amount"))
expensed= {
"date":date,
"category":category,
"description":description,
"amount":amount
}
Expenselist.append(expensed)
print("\n successfully added ")
#view all expenses details
elif (choice==2):
if (len(Expenselist)==0 ):
print("no expenses added")
else:
print("here is your all expenses and details")
count=1
for eachkharcha in Expenselist:
print(f"kharcha number {count} -> {eachkharcha["date"]}, {eachkharcha["category"]}, {eachkharcha["description"]}, {eachkharcha["amount"]}")
count=count+1
# view total expenditure
elif(choice==3):
total=0
for eachkharcha in Expenselist:
total =total + eachkharcha["amount"]
print("\n total amount =", total)
# Exit
elif(choice==4):
print("thank you")
break
#invalid
elif(choice==5):
print("invalid")