I have bigger data than this but I can use it as an example. Please, write a python 3.6 code for the question.
expenses = [['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['Malliotakis', 'Nicole', 'MA', 40000, 'Television Ads.'], ['Marte', 'Christopher', 'NY', 5152, 'Radio Ads.'], ['Yeger', 'Kalman', 'NY', 23000, 'Campgn Consuls.'], ['Marte', 'Christopher', 'CA', 5711, 'Other: explntion']]
expenses = [['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['Malliotakis', 'Nicole', 'MA', 40000, 'Television Ads.'], ['Marte', 'Christopher', 'NY', 5152, 'Radio Ads.'], ['Yeger', 'Kalman', 'NY', 23000, 'Campgn Consuls.'], ['Marte', 'Christopher', 'CA', 5711, 'Other: explntion']] # user input for last name of candidate last_name = input('Enter the last name of candidate: ') # for displaying total amount of expenses expense_amount = [row[3] for row in expenses] print('Total Expenses', sum(expense_amount)) # for displaying expenses for a particular candidate candidate_amount = [row[3] for row in expenses if row[0] == last_name] print('Expenses for candidate with last name', last_name, ':', sum(candidate_amount))
For help and modification please comment.
Thank You
I have bigger data than this but I can use it as an example. Please, write...