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
|
4627 Discussions
|
Please Login in order to post a comment
` if name == 'main': lst_name = []
if name == 'main':
not the best code but works,
why isn't this working?
if name == 'main': records=[] for _ in range(int(input())): name = input() score = float(input()) records.append([name, score])
Read the number of students
n = int(input())
Initialize an empty list to store students' name and grade pairs
students = []
Read the student data
for _ in range(n): name = input() grade = float(input()) students.append([name, grade])
Extract all the unique grades, sort them, and get the second lowest grade
grades = sorted(set([student[1] for student in students]))
Find the second lowest grade
second_lowest_grade = grades[1]
Find the names of students with the second lowest grade
second_lowest_students = [student[0] for student in students if student[1] == second_lowest_grade]
Sort the names alphabetically
second_lowest_students.sort()
Print the names
for student in second_lowest_students: print(student)