English

Identify the correct output of the following code snippet: game="olympic2024" print(game.index("C")) - Computer Science (Python)

Advertisements
Advertisements

Question

Identify the correct output of the following code snippet:

game="olympic2024"
print(game.index("C"))

Options

  • 0

  • 6

  • −1

  • ValueError

MCQ
Advertisements

Solution

ValueError

Explanation:

The character ‘C’ does not exist in the string "olympic2024". Since the index() method raises an error when the specified character is not found; a ValueError is returned.

shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×