Write a python program to count the number of words ending with Y .

 We have to count number of words which is ending with ‘Y’ or ‘y’.

Example:- This website name is easy coding zone .

        in this string only one word which is ended with ‘y’. So number of word is 1

code:-

mystring=input(“Enter a string”)
mylist=mystring.split()
no_words=0
for i in mylist:
if(i[-1]==‘y’ or i[-1]==‘Y’):
no_words+=1
print(“Number of words ending with y is=”,no_words)


Output:-

Enter a string
This website name is easy coding zone
Number of words ending with y is= 1



One thought on “Write a python program to count the number of words ending with Y .

Leave a Reply

Your email address will not be published.