Word_problem


Submit solution

Points: 6
Time limit: 5.0s
Memory limit: 12M

Author:
Problem type
Allowed languages
Python

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


  • 0
    CBSCU4CSE23713  commented on Nov. 16, 2023, 7:49 p.m.

    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}'.")


  • 0
    CBSCU4CSE23351  commented on Nov. 15, 2023, 7:01 p.m.

    A = input() for i in A: if i==A: print(i)