Why do I only print the first letters of each item in the list?
<p>I was wondering why I only print the first letter of each item I input. I would like for it to loop through the list and print each item that starts with one of the letters in the first_letters variable. </p>

<pre><code>phrase = input('Enter a list: ')
first_letters = ['A','B','C','D']
for name in phrase:
    if name[0] in first_letters: 
        print(name)

#['Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot']
</code></pre>

<p>For input Alpha,Bravo,Charlie,Delta,Echo,Foxtrot</p>

<p>If you are entering comma after each name you enter use .split(',') if you are just using space between names use .split()</p>

<p>.split() looks for an empty space and splits the user input after space and .split(',') looks for comma and splits the user input after finding comma.</p>

<pre><code>phrase = input('Enter a list: ').split(',')
first_letters = ['A','B','C','D']
for name in phrase:
   if name[0].upper() in first_letters:
      print(name)
</code></pre>

<p>To see the list of names</p>

<pre><code>print(phrase) 
</code></pre>

<p>it will show you the names in a list form after using .split() or .split(',')</p>

<p>['Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot']</p>

<p><strong>Output:</strong></p>

<pre><code>Alpha
Bravo
Charlie
Delta
</code></pre>

<p>If you want the correct names even when you use lowercase letters use this code </p>

<pre><code>phrase = input('Enter a list: ').split(',')
first_letters = ['A','B','C','D','a','b','c','d']
for name in phrase:
   if name[0] in first_letters:
      print(name)
</code></pre>

<p>For input Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,alpha,bravo,charlie,delta,echo,foxtrot</p>

<p><strong>Output:</strong></p>

<pre><code>Alpha
Bravo
Charlie
Delta
alpha
bravo
charlie
delta
</code></pre>

python