How to print only vowels contained in a string?

Asked

Viewed 83 times

-2

Implement a Python function that takes a string as a parameter and prints the vowels of that string.

Example:

string univesp must print out the characters 'u', 'i' and 'e'.

I managed to do it here, but it’s not what was asked.

str = ['univesp']

for palavra in str:
    for c in palavra:
        if c in 'aeiou':
            print(c)
  • I tested it here and it worked. You want to print everything on the same line?

1 answer

1

Although printing the requested result you did not set a function. Try:

def vogais(str):
    for c in str:
        if c in 'aeiou':
            print(c)

vogais('univesp')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.