Python-Quizzes | Python String Quiz | Question 4

Question 4: What is the output of the following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

line = "What will have so will"
L = line.split('a'
for i in L: 
    print(i, end=' '

chevron_right


(A) [‘What’, ‘will’, ‘have’, ‘so’, ‘will’]
(B) Wh t will h ve so will
(C) What will have so will
(D) [‘Wh’, ‘t will h’, ‘ve so will’]


Answer: (B)

Explanation: split() will use ‘a’ as the delimiter. It’ll create partition at ‘a’, thus split() return an array L, which is in [‘Wh’, ‘t will h’, ‘ve so will’]. For loop will print the elements of the list.

Quiz of this Question
Please comment below if you find anything wrong in the above post

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.