Write a python program to count the number of vowels in a string (No control flow allowed).

 # Input string

text = "Hello World, this is Python!"


# Convert to lowercase and use list comprehension with count

vowels = "aeiouAEIOU"


# Use sum and map to count vowels without any loops or if

vowel_count = sum(map(text.count, vowels))


print("Number of vowels:", vowel_count)

Output:



Comments