Python-Quizzes | Python List Quiz | Question 15

Question 15: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

list = ['a', 'b', 'c'] * -3
print(list)

chevron_right


(A) [‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’]
(B) [‘c’, ‘b’, ‘a’, ‘c’, ‘b’, ‘a’, ‘c’, ‘b’, ‘a’]
(C) [ ]
(D) [‘a’, ‘b’, ‘c’]


Answer: (C)

Explanation: An expression list[listelements]*N where N is an integer appends N copies of list elements in the original list. If N is a negative integer or 0 output will be an empty list else if N is positive list elements will be added N times to the original list.

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.