Python-Quizzes | Python List Quiz | Question 12

Question 12: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

list = ['python', 'learning', '@', 'Geeks', 'for', 'Geeks'
  
print(list[0:6:2])

chevron_right


(A) [‘python’, ‘@’, ‘for’]
(B) [‘Geeks’, ‘Geeks’, ‘learning’]
(C) [‘python’, ‘learning’, ‘@’, ‘Geeks’, ‘for’, ‘Geeks’]
(D) [‘python’, ‘Geeks’]


Answer: (A)

Explanation: In python list slicing can also be done by using the syntax listName[x:y:z] where x means the initial index, y-1 defines the final index value and z specifies the step size. If anyone of the values among x, y, and z is missing the interpreter takes the default value.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.