I have a long string from which I want to read the substrings and check how many times they have occurred.
The substring count taken from the user should be used for checking the frequency.
For example:
S = "ABCDEFGHIJKLMNOPQRSTUVABCSDLSFKJJKLOP"
substringCount = 3
def foo(S):
pass
The function should return a dictionary that looks like this,
{'ABC':2,'DEF':1,'GHI':1,'JKL':2,'MNO':1,'PQR':1 and so on...}
The length of each key is 3 as defined earlier, which can be user-defined and any number.
How do you write such a function? What is the logic for this?