Count Occurrences of Character

Advanced

Welcome to the "Count Occurrences of Character" challenge! 🐍

In this fun and educational challenge, you will create a function to help count how many times a specific character appears in a given sentence. Think of it like being a detective, but for letters! πŸ”

Let's say we have the sentence: "I love coding!", and our target character is 'o'.

Your task is to count the number of times 'o' appears in the sentence.

Example:

count_occurrences("I love coding!", 'o')

This would return 2 because the letter 'o' appears twice.

Try out with different sentences and characters, and see if your function can find all the occurrences each time! 🎯

Here are more examples:

  • count_occurrences("Bananas are great!", 'a') should return 4.
  • count_occurrences("Hello, World!", 'l') should return 3.

Let's start making those characters feel counted! ✨

Geek
Inputs

Arg 1:

"I love coding!"

Arg 2:

"o"
Expected Output
2
Actual Output