Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate.
Answers
Answered by
1
def get_election_results():
res = {}
for x in range(1, 6):
name, votes = input(f"enter name_{x}: "), int(input("enter votes: "))
res[name] = votes
print()
return dict(sorted(res.items(), key = lambda item: item[1], reverse = True))
for k, v in get_election_results().items():
print(f"{k}: {v}")
Similar questions