Problem 163715 · easy · Phase 01 Prerequisites & Setup

How Hard Did They Laugh?

strings · count · lower

A chat message is a laugh if it contains ha. Given msg, return how many times ha appears, ignoring case and counting non-overlapping occurrences from left to right.

Examples

Input:  msg = "hahaha"
Output: 3

Input:  msg = "HA! That was hard"
Output: 3

Constraints

  • 0 <= len(msg) <= 5000
  • msg may contain letters, digits, spaces and punctuation

Goals

  • Count non-overlapping occurrences of a substring
  • Ignore letter case
Starting Python…