Friday 18 November 2022

Python program to check atleast two vowels matching words and word count from paragraph or string



def vowels_count(string):
    vowels=['a','e','i','o','u','A','E','I','O','U']
    var1 =  string.split(" ")
    var = [vowel for vowel in var1 if sum(ch in vowels for ch in vowel) >= 2 ]
    var2 = len(var)

    print (var)
    print (var2)


string="Horse knows when he is going to race. How does he know? His breakfast was scanty. (He is angry about that.) He does not have saddle on his back. He is being led, not ridden, to grandstand. He is led under grandstand into unusual, special stall. Horse is nervous. Sometimes he does not know what to do when starting gate flies open and track is before him. If he does not begin to run instantly, other horses are already ahead of him. During race, when he sees another horse just ahead of him,"


vowels_count(string)

Labels: , ,