'How do you check if a string has something from the list and print it?

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 1:[1]

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))

Solution 2:[2]

Use the sum() function to count the number of vowels in the word. The generator expression produces True for each vowel that is found at least once, and True counts as 1 to sum().

vowelCount = sum(vowel in userWord for vowel in vowels)
print(f"There are {vowelCount} total vowels in {userWord}")

Solution 3:[3]

vowels=['a','e','i','o','u']
count=0
ls=[]
wordfromUser=input("Enter a word: ")
for i in wordfromUser:
  if i in vowels:
    count+=1
    ls.append(i)
print("There are " + str(count) + " total vowels in " + wordfromUser)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 ajaykalidindi