May-24-2018, 03:53 PM
Please help. Show me how to do this. Have indented code and get no complaint.
As it is still only reports last item. What is correct?
The plan is to work with 11 categories.
tia
Example of expenses-18.
012118,1,1.00,1
022218,2,2.22,2
032318,3,33.33,3
042418,4,44.44,3
As it is still only reports last item. What is correct?
The plan is to work with 11 categories.
tia
Example of expenses-18.
012118,1,1.00,1
022218,2,2.22,2
032318,3,33.33,3
042418,4,44.44,3
#!/usr/bin/python x = 0 tamt = 0 with open('expenses-18', 'r') as file: for line in file: pdate,catg,amt,howp = line.split(",") catg = int(catg) tamt = tamt + float(amt) x = x + 1 print 'cnt > ',x ,'catg :', catg if catg == 1: print '* line > ', line elif catg == 2: print '** line > ', line elif catg == 3: print '*** line > ', line elif catg == 4: print '**** line > ', line print ' ##\n' print 'total amt > ',tamt