I have two lists. one of candidates and one of votes received. I want to sort them descending by votes received. Zipping works fine. When I print the type of the resultant list it comes back as class 'list'. Next I sort and, bam!, get an AttributeError: 'tuple' object has no attribute get
. I don't know how to fix this and would appreciate guidance.
for i in range(len(uniquecandidate)):
result = zip(uniquecandidate, votes) # zips two lists together
result_list = list(result)
print(type(result_list)) # returns <class 'list'>
result_list.sort(key=lambda x: x.get('votes'), reverse=True) #sort by vote number
print(result_list, end='\n\n')