QuestionQ222

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

What is the expected output of this code?

Question Image

Explanation

Python’s str.count(sub, start) counts non-overlapping occurrences of sub within the string slice beginning at start. Starting at index 1 excludes the initial ab, so two ab occurrences remain.

Community Discussion

No comments yet. Be the first to start the discussion!