Skip to content
Related Articles
Open in App
Not now

Related Articles

Python-Quizzes | Python String Quiz | Question 4

Improve Article
Save Article
  • Last Updated : 18 Sep, 2020
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!