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 char_occurences(strng, char): count = 0 for c in strng: if c == char: count += 1 return count char_occurences('hello', 'l')

Questions about programming?Chat with your personal AI assistant