Добавил:
Silebox
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
disciplines = tuple(['физика','математика','информатика','АСВТ','русский язык'])
x = input('Введите название дисциплины: ')
needed = disciplines.index(x) + 2
with open('var2.txt', 'rt') as f:
f.readline()
students = []
for i in f.readlines():
student = [j.strip() for j in i.split('|')]
value = student[needed].strip()
if value == '1': students.append(student)
if len(students) > 8:
students = sorted(students,key=lambda x: float(x[7]))
while len(students) != 8: students.pop(0)
[print(student[0]) for student in students]
x = input('Введите название дисциплины: ')
needed = disciplines.index(x) + 2
with open('var2.txt', 'rt') as f:
f.readline()
students = []
for i in f.readlines():
student = [j.strip() for j in i.split('|')]
value = student[needed].strip()
if value == '1': students.append(student)
if len(students) > 8:
students = sorted(students,key=lambda x: float(x[7]))
while len(students) != 8: students.pop(0)
[print(student[0]) for student in students]