Define a function getSeconds() that accepts one argument: a list of lists. getSeconds() should return the second item in every sublist that has at least two items. If the sublist has fewer than two items, it should be ignored. For example:
getSeconds([[1,2], ['a', 'b', 'c'], ['x'], [10, 20]]) should be [2, 'b', 20]
Here is the required solution in python language
here is the code
#function defination
def getSeconds(lis):
l=[]
for x in lis:
if len(x)>=2:
l.append(x[1])
return l
#test case
print(getSeconds([[1,2],['a','b','c'],['x'],['10','20']]))
Get Answers For Free
Most questions answered within 1 hours.