Computer Science, asked by kamranrana786, 5 months ago

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 jai696
1

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

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}")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions