I got a question with getting two highest number from lists and when I made a code and tested it, the actual outcomes is a bit different to what I was expected. I was expecting to get only numbers but and outcomes give names with numbers and even it comes with wrong numbers when I changed a #TEST. What should I do with them? Thank you. What I have tried: <pre lang="Python">import heapq def get_two_highest_marks(names_marks_list): a = heapq.nlargest(2, names_marks_list) return a #TEST names_marks = [("Ian", 78), ("Siggy", 88), ("Andy", 68), ("Irene", 90), ("Gio", 59)] top_two = get_two_highest_marks(names_marks) print(top_two)
[88, 90]
[('Siggy', 88), ('Irene', 90)]
answer = get_two_highest_marks(names_marks) top_two = [num[1] for num in answer] print(top_two)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)