title: returning the 2nd letter in a string in a list and sorted the words by it. keep getting indexing range out of bound. Python
body: <p>I am working on an assignment with the below requirements:</p>
  
  <p>You will be sorting the following list by each element’s second letter, a to z. Create a function to use when sorting, called second_let. It will take a string as input and return the second letter of that string. Then sort the list, create a variable called sorted_by_second_let and assign the sorted list to it. </p>
  
  <p>This is my code:</p>
  
  <pre><code>ex_lst = ['hi', 'how are you', 'bye', 'apple', 'zebra', 'dance']
  
  def second_let(x):
  
      lst= []
      for wrd in x:
          lst.append(wrd[1])
      return lst
  
  print(second_let(ex_lst))
  print(sorted(second_let(ex_lst)))
  
  sorted_by_second_let= sorted(ex_lst, key= second_let)
  
  </code></pre>
  
  <p>I keep getting this error:</p>
  
  <blockquote>
    <p>IndexError: string index out of range on line 7, which is the lst.append(wrd[1]). what am I doing wrong? how can I do it better?</p>
  </blockquote>
  
  <p>Thank you.</p>