Display vowels in a string using for loop 1

Display vowels in a string using for loop

text = input('Enter text: ')

for char in text:
    if char.lower() in 'aeiou':
        print(char)

Here is what the above code is Doing:
1. We create a variable called text and assign it the value of the input from the user.
2. We create a for loop that iterates through each character in the text variable.
3. We create an if statement that checks if the character is in the string ‘aeiou’.
4. If the character is in the string, we print it.

Similar Posts