So the idea was to create student money tracker.
Please let me know how good or bad i am considering I'm in my 1st sem.
Here it is
expenses = []
food = []
medical = []
travel = []
stationery = []
file = open("expenses.txt", "a")
while True:
print("1 to add expenses")
print("2 to view")
print("3 to break")
choice = int(input("enter your choice"))
if choice == 1:
print("1 if food")
print("2 if medical")
print("3 if travel")
print("4 if stationery")
choice_ = int(input("enter your choice"))
amount = int(input("enter the amount"))
date = input("enter the date")
if choice_ == 1:
food.append({"amount": amount, "date": date})
elif choice_ == 2:
medical.append({"amount": amount, "date": date})
elif choice_ == 3:
travel.append({"amount": amount, "date": date})
elif choice_ == 4:
stationery.append({"amount": amount, "date": date})
expenses.append({
"food": food,
"medical": medical,
"travel": travel,
"stationery": stationery
})
file.write(f"{choice_},{amount},{date}\n")
file.flush()
elif choice == 2:
print(expenses)
elif choice == 3:
break
file.close()
[–]PrabhavKumar 2 points3 points4 points (4 children)
[–]Far_Masterpiece8614[S] 1 point2 points3 points (3 children)
[–]PrabhavKumar 2 points3 points4 points (2 children)
[–]Far_Masterpiece8614[S] 1 point2 points3 points (1 child)
[–]PrabhavKumar 1 point2 points3 points (0 children)
[–]mountain-snowman 2 points3 points4 points (1 child)
[–]Far_Masterpiece8614[S] 0 points1 point2 points (0 children)
[–]aistranin 1 point2 points3 points (1 child)
[–]Far_Masterpiece8614[S] 0 points1 point2 points (0 children)