Pyhton3 Question about dictionaries and lists
Task = Create a dictionary with this information (Smith - 8,5 ; Peters - 7,5; Jones - 4,5; Morgan - 6,0; Owens - 6,0). Write a program which takes the name as input from a user, and prints out the name, grade,and rank in the class. The name should not be case sensitive (e.g., "peter", "PETER", "Peter", etc should all be recognized correctly). This is my code but when I input the new person's information then the list is not sorted in order. Can anyone help please ? students= {"Smith":8.5 , "Peters":7.5 , "Jones" :4.5 ,"Morgan" :6.0 , "Owens" :6.0} newstudent= input ("please enter your name").lower() gr = input ("please enter your grade ").lower() students[newstudent]= gr keylist = list( students.keys() ) keylist.sort(reverse= True) for key in keylist: print( "{}:{}".format( key, students[key] ) ) the output I get is: (inputted john as name and 7 as grade) john:7 Smith:8.5 Peters:7.5 Owens:6.0 Morgan:6.0 Jones:4.5