9 ms·
Looks like it exists, and works (at least for strings): >>> 'test'.count('e') 1 >>> 'test'.count('') 5 >>> 'test'.count('tes') 1 >>> 'test'.count
by TazeTSchnitzel 14y ago
Looks like it exists, and works (at least for strings):
>>> 'test'.count('e')
1
>>> 'test'.count('')
5
>>> 'test'.count('tes')
1
>>> 'test'.count('t')
2
>>> 'test'.count('apple')
0
Seems to be the equivalent of `in` on a string but with a count.
- nemetroid 14y agoIt does exist for strings, but the list contains both `.count('string2')` and `.count(object1)`.
- TazeTSchnitzel 14y agoIt also works on lists, I think he got confused.