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>Supply provide an a list comprehension to <code>print</code> and unpack it:</p>

<pre><code>&gt;&gt;&gt; s = "Hey there, everything allright?" # received from input
&gt;&gt;&gt; print(*[i for i in s if i in 'aeiou'])
e e e e e i a i
</code></pre>

<p>This makes a list of all vowels and supplies it as positional arguments to the print call by unpacking <code>*</code>.</p>

<p>If you need distinct vowels, just supply a set comprehension:</p>

<pre><code>print(*{i for i in s if i in 'aeiou'}) # prints i e a
</code></pre>

<p>If you need to add the else clause that prints, pre-construct the list and act on it according to if it's empty or not:</p>

<pre><code>r = [i for i in s if i in 'aeiou']  
if r:
   print(*r)
else:
   print("empty")
</code></pre>

python string python-3.x printing