Identify the correct output of the following code snippet : game="olympic2024"निम्नलिखित कोड स्निपेट (Code Snippet) का सही आउटपुट (Out put) बताइये :
Identify the correct output of the following code snippet :
game="olympic2024"
print (game. index ("C") )
निम्नलिखित कोड स्निपेट (Code Snippet) का सही आउटपुट (Out put) बताइये :
game="olympic2024"
Print (game. Index ("C") )
Show answerHide answer
Correct answer: (D) valueErrorvalueError
Explanation
str.index() raises ValueError when the substring is not found. "olympic2024" contains a lowercase "c" but no uppercase "C", so the code raises ValueError. find() would return -1 instead.str.index() सबस्ट्रिंग न मिलने पर ValueError उठाता है। "olympic2024" में छोटा "c" है पर बड़ा "C" नहीं, इसलिए कोड ValueError उठाता है। find() इसके बजाय -1 लौटाता।