Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


It does exist for strings, but the list contains both `.count('string2')` and `.count(object1)`.


It also works on lists, I think he got confused.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: