I have a doctest written:
def extract_second(triples): """Given a list of triples, return a list with the second element of each triple
If an item is not a triple, return None for that element
>>> extract_second([('a',3,'x'),('b',4,'y')])
[3, 4]
>>> extract_second([('c',5,'z'),('d',6)])
[5, None]
>>> extract_second([('a',3,'x'),('b',4,'y')]) == [3, 4]
True
"""
for x in triples:
return x[1]
although the code is not returning the 1st index of the 2nd list inputted. Any ideas?
Aucun commentaire:
Enregistrer un commentaire