एक स्ट्रिंग x=”hello” दिया गया x.count('l') का आउटपुट क्या है?
Given a string x=”hello” What is the output of x.count(‘l’) ?
A
2
B
1
C
0
D
none
Explanation
The count() method in Python counts how many times a specified substring appears in a string.
For the string x = "hello", if you call x.count('l'), it counts the occurrences of the character 'l'.
- In the string
"hello", the letter'l'appears 2 times.
Thus, the output is:
(A) 2
Correct Answer: A) 2