Open In App

Python-Quizzes | Python String Quiz | Question 4

Like Article
Like
Save Article
Save
Share
Report issue
Report

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




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


(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


Last Updated : 18 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads