We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Basic Data Types
- Nested Lists
- Discussions
Nested Lists
Nested Lists
Sort by
recency
|
4251 Discussions
|
Please Login in order to post a comment
unique_values = sorted(set((x[1] for x in records)))
if len(unique_values) > 1: second_lowest = unique_values[1]
**When I test this with the input from the exercise it is working fine, but when I test the code here it print multiple time the same name and it is an error. Anybody knows why?*
if name == 'main': lst = [] for _ in range(int(input())): name = input() score = float(input()) lst.append([name,score]) lst.sort(key = lambda x : x[1]) mini = lst[0][1] lst1 = [] for t in lst: if(t[1]>mini): lst1.append(t) mini2 = lst1[0][1] lst1.sort(key = lambda x: x[0])
records = list()
AllScores = set()
for _ in range(int(input())): name = input() score = float(input()) records.append([name, score]) AllScores.add(score)
AllScores = list(AllScores) AllScores.sort()
sol = list() for i in records: if AllScores[1] in i: sol.append(i[0]) sol.sort() print("\n".join(sol))
n=[["Harry", 37.21],["Berry", 37.21],["Tina", 37.2],["Akriti", 41],["Harsh", 39]] sort_grades= sorted(n, key= lambda x: x[1])
lowest_grade= sort_grades[1][1]
student_with_lowest_grade=[x[0] for x in sort_grades if x[1] == lowest_grade ]
sorting alphabetcally
student_with_lowest_grade.sort()
for student in student_with_lowest_grade: print(student)
if name == 'main': all_students = [] all_score = [] filtred_score = [] second_students = [] for _ in range(int(input())): name = input() score = float(input()) one_student = [name,score] all_students.append(one_student)