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

Want to kickstart your project?Use the new AI Studio to create your code