Computer Science, asked by chirag11082009, 2 months ago

Write a program in python to input a string from the user and display the word in which maximum time alphabet 'e' appears​

Answers

Answered by allysia
2

Language:

Python

Program:

st=input("Enter a sentence:").lower().split(" ")

di={}

for i in st:

   count=0

   for j in i:

       if j=="e":

           count+=1

       else:

           pâss

   di[i]=count

val=max(di.values())

print(f"Maximum number e = {val} in:")

for i in di:

   if di[i]==val:

       print(i)

Output:

Consider the attachment

Logic:

  • Input a sentence
  • Split it into words after making them of same case (here by using word.lower().split())
  • Initialize a dictionary
  • Check using nested loop for "e" and save the key as the word and value as the count.
  • Get maximum value.
  • print word/s.

Attachments:
Similar questions