Advertisements
Advertisements
Question
Identify the correct output of the following code snippet:
game="olympic2024"
print(game.index("C"))Options
06−1ValueError
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?
