Advertisements
Advertisements
Question
What is the output of the expression?
country='International'
print(country.split("n"))
Options
('I', 'ter', 'atio', 'al')
['I', 'ter', 'atio', 'al']
['I', 'n', 'ter', 'n', 'atio', 'n', 'al']
Error
MCQ
Solution
['I', 'ter', 'atio', 'al']
Explanation:
- The split() method in Python divides a text into a list of substrings using the separator specified. The separator is "n"; hence, any occurrence of the letter "n" will be used to separate the string.
- 'International' split by
"n"
becomes:'I'
'ter'
'atio'
'al'
- Thus, the result is:
['I', 'ter', 'atio', 'al']
shaalaa.com
Is there an error in this question or solution?