adplus-dvertising
frame-decoration

Question

What will be the output?
def example(L):
    ''' (list) -> list
    '''
    i = 0
    result = []
    while i < len(L):
        result.append(L[i])
        i = i + 3
    return result

a.

Return a list containing every third item from L starting at index 0

b.

Return an empty list

c.

Return a list containing every third index from L starting at index 0

d.

Return a list containing the items from L starting from index 0, omitting every third item

Posted under Python

Answer: (a).Return a list containing every third item from L starting at index 0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output?