Print only vowels in a string
<p>I am new in Python and I'm trying to print all the vowels in a string. So if someone enters "Hey there, everything alright?" , all vowels needs to be printed...but I don't know how? (so it's not about counting the vowels, its about printing the vowels)</p>

<p>For now I've got this ;</p>

<pre><code>sentence = input('Enter your sentence: ' )

if 'a,e,i,o,u' in sentence:
    print(???)

else:
    print("empty")
</code></pre>

<p>The two answers are good if you want to print <em>all</em> the occurrences of the vowels in the sentence -- so "Hello World" would print 'o' twice, etc.</p>

<p>If you only care about <em>distinct</em> vowels, you can instead loop over the vowels.  In a sense, you're flipping the code suggested by the other answers:</p>

<pre><code>sentence = input('Enter your sentence: ')

for vowel in 'aeiou':
    if vowel in sentence:
        print(vowel)
</code></pre>

<p>So, "Hey there, everything alright?" would print</p>

<pre><code>a e i
</code></pre>

<p>As opposed to:</p>

<pre><code>e e e e e i a i
</code></pre>

<p>And the same idea, but following Jim's method of unpacking a list comprehension to <code>print</code>:</p>

<pre><code>print(*[v for v in 'aeiou' if v in sentence])
</code></pre>

python string python-3.x printing