Hi All,

I need help to understand hoe does this find() works in the case of, find Total occurrences of a substring.

This is my assignment question.

[Thread 1]

Recommended Answers

All 2 Replies

I am doing some searches on Google, if I find any relevant sources will update the question.

[Thread 2]

What is the answer to the total occurrences when the string is "aaaaaaaaa" and the substring is "aa"? For some it will be 5 and others will be around 8.

That aside https://www.w3schools.com/python/ref_string_find.asp doesn't do this count. You would have to wrap find() with code to step through the string and increment a count on each success of find().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.