Vidyalelo
Python · Q36

Python Lists MCQs: Exam Practice for List Concepts

Programming · Python · question 36

Q36

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
Answer
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

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board