Question: I'm having issues with Python dictionaries with lists containing tuples. Here's the folder with the csv and tester files: https://drive.google.com/drive/folders/1yYfSuRecJzeZSzm6UGfhC23WB8dmu0eI?usp=sharing Here's my code so far:


![so far: def read_votes(filename): db1 = {} info_db1 = [] with open(filename,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5aa1fac7d5_90366f5aa1f211ae.jpg)

I'm having issues with Python dictionaries with lists containing tuples.
Here's the folder with the csv and tester files:
https://drive.google.com/drive/folders/1yYfSuRecJzeZSzm6UGfhC23WB8dmu0eI?usp=sharing
Here's my code so far:
def read_votes(filename):
db1 = {}
info_db1 = []
with open(filename, 'r') as f:
f.readline()
for line in f:
if(count == 5):
str = line.split(',')
str[1] = str[1] + ',' + str[2]
else:
info_db1 = line.split(',')
#think setup
#AL: [(Johnson, IND, 44467, 0), (Stein, IND, 9391, 0)],
db1[info_db[1]] = (info[0]), info[2], int(info_db[3]), int(info_db[4]) == 'True')
return db1
![= line.split(',') str[1] = str[1] + ',' + str[2] else: info_db1 =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5aa219a5fb_90566f5aa2113404.jpg)
dictionaries and file I/O Background The purpose of this assignment is to explore dictionaries and file reading and writing. We will be reading in some data about US elections', creating a structure that groups data by State, and then checking for various statistics What's attowed? here is the exhaustive list of things you can use on the project. all basic expressions/operators, indexing/slicing . all basic statements: assignment, selection, and loop statements, break/continue, return . functions: len), range). min), max(), int), str0, enumerate0. round0) .file Teading: open), close(), read), readline(), readlines0, with syntax methods: lists: .remove(), .insert), .append), .extend), .pop(), .popitem) strings: .strip(), .split(), .join(), .remove(), .insert(), .lower0 . reversed), reverse() This means that... you can't call anything not listed above. Focus on applying these functions to solve the task. you can't import any modules for this project. (so you can't import csv either but it isn't that helpful) dictionaries and file I/O Background The purpose of this assignment is to explore dictionaries and file reading and writing. We will be reading in some data about US elections', creating a structure that groups data by State, and then checking for various statistics What's attowed? here is the exhaustive list of things you can use on the project. all basic expressions/operators, indexing/slicing . all basic statements: assignment, selection, and loop statements, break/continue, return . functions: len), range). min), max(), int), str0, enumerate0. round0) .file Teading: open), close(), read), readline(), readlines0, with syntax methods: lists: .remove(), .insert), .append), .extend), .pop(), .popitem) strings: .strip(), .split(), .join(), .remove(), .insert(), .lower0 . reversed), reverse() This means that... you can't call anything not listed above. Focus on applying these functions to solve the task. you can't import any modules for this project. (so you can't import csv either but it isn't that helpful)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
