У меня есть список, содержащий Student
объектов со следующими признаками: name
, hours
и qpoints
. Список хранится в переменной data
. Почему я получаю возврат None
в следующем? Другими словами, data.sort(key = Student.gpa)
возвращает None
, хотя существует способ, возвращающий gpa в классе Student
. Я импортировал класс Student
в свой код.заказ списка python список объектов
def choiceInput(data):
choice = input('Enter method of sorting <GPA>, <Name>, or <Credits>: ')
choice = choice[0].lower()
if choice == 'g':
return data.sort(key = Student.gpa)
elif choice == 'n':
return data.sort(key = Student.getName)
else:
return data.sort(key = Student.getpPoints)
Где я могу найти эту угрозу? – lhoernle