I have written a basic code to count the number of vowels in a given string using a for loop. I am wondering if there is a more elegant way of writing the code?
The code which works:
words = input(str("Enter a word:")) #String input from user
words_list = list(words) #Convert user input to a list
vowels = ["a", "e", "i", "o", "u"] #Define vowels list
number = 0 #No: of vowels set to 0
for word in words_list:
if word in vowels:
number += 1
print(f"The number of vowels in {words} are {number}")