Examveda

What will be the output of the following Python code?
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

Answer: Option A


This Question Belongs to Python Program >> Lists In Python

Join The Discussion

Related Questions on Lists in Python