हिंदी

What is the output of the following code snippet? s=‘War and Peace by Leo Tolstoy’ print(s.partition(“by”)) - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

What is the output of the following code snippet?

s=‘War and Peace by Leo Tolstoy’

print(s.partition(“by”))

विकल्प

  • ('War and Peace ', 'by', ' Leo Tolstoy')

  • ['War and Peace ', 'by', ' Leo Tolstoy']

  • ('War and Peace ', ' Leo Tolstoy')

  • ['War and Peace ', ' Leo Tolstoy']

MCQ
Advertisements

उत्तर

('War and Peace ', 'by', ' Leo Tolstoy')

Explanation:

s.partition(“by”) returns a 3-tuple: (text before, separator, text after). For the given string, it produces ('War and Peace’, ‘by’, ‘Leo Tolstoy’); note that the spaces remain with the surrounding parts.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×