Let's say I want to find the word dad in a random string only containing the letters 'd' and 'a'. For example, the string could be daddadaadaddaadadddadad. How would I go about making a program that could find how many instances of 'dad' there is? And for more detail 'dadad' is 2 instances of 'dad'.
Asked
Active
Viewed 31 times
0
-
3Have you tried anything? Do you know about python strings? What about regex? – doctorlove Jun 02 '17 at 15:07
-
Try it and come back if you have a specific issue. The solution should be fairly short. – mrogers Jun 02 '17 at 15:07
-
1https://stackoverflow.com/questions/2970520/string-count-with-overlapping-occurrences – Ilja Everilä Jun 02 '17 at 15:08
-
3It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (console output, tracebacks, etc.). The more detail you provide, the more answers you are likely to receive. Check the [FAQ] and [ask]. – MooingRawr Jun 02 '17 at 15:08
-
1Did not see @Ilja Everilä's post when looking for answers. Thank you for bring it to my attention, that post is what I needed. Thank you. – Zane Papek Jun 02 '17 at 15:14