EX 1 - SUJET 25

 avatar
unknown
python
3 years ago
479 B
3
Indexable
animaux = [ {'nom':'Medor', 'espece':'chien', 'age':5, 'enclos':2},
{'nom':'Titine', 'espece':'chat', 'age':2, 'enclos':5},
{'nom':'Tom', 'espece':'chat', 'age':7, 'enclos':4},
{'nom':'Belle', 'espece':'chien', 'age':6, 'enclos':3},
{'nom':'Mirza', 'espece':'chat', 'age':6, 'enclos':5}]



def selection_enclos(table_animaux,num_enclos):
    table = []
    for x in table_animaux:
        if x['enclos'] == num_enclos:
            table.append(x)
    return table
Editor is loading...