Python Forum
Python: Returning the most frequently occurring substring in a larger string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python: Returning the most frequently occurring substring in a larger string
#3
(Feb-09-2018, 06:33 AM)metulburr Wrote: what have you tried so far?
I have found out how to find how many times 1 letter appears in a code:

def longestRepeat(x, y):
    count = 0
    longest = 0
    i = x
    while i in y:
        count+=1
        i = x*(count+1)
    return count
BUT I cannot figure out how to have it search through a given string on it's own for the most common.
Reply


Messages In This Thread
RE: Python: Returning the most frequently occurring substring in a larger string - by sskkddrit - Feb-09-2018, 06:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Finding how many times substring is in a string using re module ranbarr 4 3,965 May-21-2021, 06:14 PM
Last Post: nilamo
  Returning data from a pyobjc object to python environment newpythonuser100 3 3,519 Jul-28-2020, 12:08 PM
Last Post: newpythonuser100
  Substring in a string Propoganda 1 2,981 Dec-01-2019, 08:45 AM
Last Post: perfringo
  Find a substring in a dictonary; value substring of key aapurdel 2 8,539 May-31-2019, 06:14 PM
Last Post: ichabod801
  [Discussion] Re. Substring counting Mekire 9 7,040 Jan-22-2018, 01:56 PM
Last Post: wavic
  array replace with 1 when larger than 1 metalray 1 3,338 Nov-01-2017, 07:25 PM
Last Post: Mekire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020