Write a Python program which will ask for 3 student names their scores. Then your program will find the top 3 students on their scores. It will print the student name & score with the highest score in dictionary. NOTE: all of the students will have unique names. NO NAMES SHOULD NOT BE REPEATED.


Write a Python program which will ask for 3 student names their scores. Then your program will find the top 3 students on their scores. It will print the student name & score with the highest score in dictionary.
NOTE: all of the students will have unique names. NO NAMES SHOULD NOT BE REPEATED.

sample input:
devang
34
ryan
67
uma
23
sample output:
{'ryan': 67}

sample input:
raj
12
ravi
55
samip
89
sample output:
{"samip": 89}

ANS:

student_data = {}
for student in range(3):
student_name = input()
student_score = int(input())
student_data[student_name] = student_score

student_list = []
for key in student_data:
student_list.append({key: student_data[key]})

student_list.sort(key=lambda x: list(x.values()), reverse=True )

print(student_list[0])