English

What is the output of the expression? country='International' print(country.split("n")) - Computer Science (Python)

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:

  1. 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.
  2. 'International' split by "n" becomes:
    1. 'I'
    2. 'ter'
    3. 'atio'
    4. 'al'
  3. Thus, the result is:
    ['I', 'ter', 'atio', 'al']
shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×