generate functionTue, 21 Mar 2023

Write a program that finds the record number of occurrences (not necessarily consecutive) of a character in a string.

def find_occurrences(s, c): count = 0 for i in range(len(s)): if s[i] == c: count += 1 return count

Questions about programming?Chat with your personal AI assistant