एक स्ट्रिंग 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 correct answer is (A) 2.
Explanation:
- The
count()method in Python returns the number of times a specified value appears in the string. - In the string
x = "hello", the character'l'appears twice. - Therefore,
x.count('l')will return 2.
Correct Answer: A) 2