About 252,000 results
Open links in new tab
  1. python - Count the number of occurrences of a character in a …

    How do I count the number of occurrences of a character in a string? e.g. 'a' appears in 'Mary had a little lamb' 4 times.

  2. How do I count the occurrences of a list item? - Stack Overflow

    Apr 8, 2010 · 2220 Given a single item, how do I count occurrences of it in a list, in Python? A related but different problem is counting occurrences of each different element in a collection, …

  3. python - Count number of occurrences of a substring in a string

    Following previous comment, you might want to see: python: How to find a substring in another string or Basic indexing recurrences of a substring within a string (python). As this seems a …

  4. python - Count occurrences of a substring in a list of strings

    Aug 17, 2017 · d_count = data.count(any('foo' in s for s in data)) print("d_count:", d_count) but that also gives zero as a result. I would like to know how to count each occurrence of substring …

  5. How to get the size (length) of a string in Python

    There are 2,161,081 Python questions. This sounds like an answer to a different question, like How can I count characters in a string without the white spaces using Python?. Protected …

  6. python - Count letter differences of two strings - Stack Overflow

    Sep 1, 2012 · The Theory Iterate over both strings simultaneously and compare the characters. Store the result with a new string by adding either a spacebar or a | character to it, …

  7. Python - Count number of words in a list strings - Stack Overflow

    Sep 16, 2013 · Python - Count number of words in a list strings Asked 12 years, 3 months ago Modified 2 years, 8 months ago Viewed 81k times

  8. Python: count repeated elements in the list - Stack Overflow

    Apr 23, 2014 · Closed 3 years ago. I am new to Python. I am trying to find a simple way of getting a count of the number of elements repeated in a list e.g.

  9. Python Lists - Finding Number of Times a String Occurs

    'votes' is your "list" containing duplicate strings that you want to count. And set () doesn't SET anything, it converts the list to a set by removing duplicates.

  10. Count occurrences of each of certain words in pandas dataframe

    49 I want to count the number of occurrences of each of certain words in a data frame. I currently do it using str.contains: