-1
name
,hours
およびqpoints
の属性を持つStudent
オブジェクトを含むリストがあります。リストは変数data
に格納されます。なぜ私はNone
の返品を次のようにしていますか?つまり、クラスのgpaを返すメソッドがあっても、data.sort(key = Student.gpa)
はNone
を返します。コード内に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