Little program about calculating


I try make a little program, which will calculate expenses.
I ended chapter ‘Battleships’ so I am in mid of course
Right now I have something like this(it’s only sketch):

expense = {
“cat1”: ,
“cat2”: ,
“cat3”: ,

option1 = “1. I wanna add expense”
option2 = “2. blabla”

print “Hi, what do you want to do?”
print option1
print option2

choice = int(raw_input("My choice is ")

if choice == 1:
print “List of categories”
for i, key in enumerate(expense):
print i, key

chcat = raw_input("Which cat do you want to choose?")
if chcat in expense.keys():
    print "You chose " + str(chcat)

After step where user chose a category he should input cost, so:

cost = float(raw_input("How much? ")

And here I have a problem. How to add cost to category? My categories are strings, and their values are stored in list. In codecademy’s chapter with students these data were input manually before.
Any ideas?

Like so,


Easy enough?

1 Like

Ou, I didn’t know (or probably remember…) this formula.
Thank you :smiley: