1(xix)
Function to count the number of items in a string 'a' in Python is ............... .
- (a)string.cnt('a')
- (b)count.string('a')
- (c)cnt.string('a')
- (d)string.count('a')
Show SolutionHide Solution↓
string.count('a')
Reason — The count() function is a string method that counts the number of times a particular character or substring occurs in a string. Its correct syntax is string.count('a'). The other options are not valid Python string methods.