У меня есть список объектов Note под названием notesList
. Я хочу отфильтровать свой список на основе свойства codeCours
в функциональном шаблоне с использованием лямбды, где я хочу сохранить только объекты, имеющие одинаковые codeCours
.
со списком Note
объектов.
notesList = [Note(numeroEtudiant=1, codeCours=11, note=14),
Note(numeroEtudiant=2, codeCours=11, note=16),
Note(numeroEtudiant=2, codeCours=13, note=16)]
Я хочу получить все заметки со значением для codeCours
из 11:
[Note(numeroEtudiant:1 codeCours:11 note:14,
Note(numeroEtudiant:2 codeCours:11 note:16)]
Note
построено с
class Note:
def __init__(self, numeroEtudiant, codeCours, note):
self.numeroEtudiant = numeroEtudiant
self.codeCours = codeCours
self.note = note