I have to use doctest to run and check the following
>>> extract_second([('a',3,'x'),('b',4,'y')])
[3, 4]
I was able to run this successfully using :
x[1] for x in elements
but the second test was not successful which is:
>>> extract_second([('c',5,'z'),('d',6)])
[5, None]
then i used the following code to work it out by a little bit research
lst=[(1,2,3),(4,5,6)]
for i in lst:
if len(i) != 3:
print "None"
else:
print i[1],
Earlier I was able to print the output as required but brackets and comma was not included in it
Expected outcome:
[3,4]
[5, None]
Received output:
3 4
5 None
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…