Word_problem
Submit solution
Python
Points:
6
Time limit:
5.0s
Memory limit:
12M
Author:
Problem type
Allowed languages
Write a Python program to find the occurrences of a character in a given word
Input:
Input is a word and a character to find the occurrence
Output:
Result is a Integer value that shows the count of the character in the word
Sample Input
amrita
a
Sample Output
2
Comments
def count_occurrences(word, char): return word.count(char)
Sample Input
word = input("Enter a word: ") character = input("Enter a character: ")
Sample Output
result = count_occurrences(word, character) print(f"The character '{character}' occurs {result} times in the word '{word}'.")
A = input() for i in A: if i==A: print(i)