I’m trying to make a program that takes one word from the user and checks from a list of vowels and prints the vowels that are found in that word and how many were found. This is what I have so far, it’s super incorrect but I tried something.
print("This program will count the total number of vowels in the word you enter.")
vowels = ["a", "e", "i", "o", "u"]
userWord = input("Please enter a single word: ")
if vowels in userWord:
print(vowels)
vowelCount = 0
vowelCount = vowelCount + 1
print("There are " + vowelCount + " total vowels in " + userWord)
>Solution :
Something you can do if you are starting out with Python is to iterate over every letter in the input word.
In each iteration you then check if the letter is in the vowel list like so:
print("This program will count the total number of vowels in the word you enter.")
vowels = ["a", "e", "i", "o", "u"]
userWord = input("Please enter a single word: ")
vowelCount = 0
foundVowels = []
for letter in userWord:
if letter in vowels:
foundVowels.append(letter)
vowelCount += 1
print("There are " + str(vowelCount) + " total vowels in " + userWord + ": " + str(foundVowels))