title: Sorting a list of names and dates according to birthday
body: <p>I have a text file in this format:</p>
  
  <pre><code>Robert, 03/07/1960
  Michael, 24/11/1942
  Simon, 14/08/1924
  Sarah, 20/07/1935
  Adam, 12/09/1944
  Rachael, 24/09/1919
  </code></pre>
  
  <p>So is has name and birthday separated by a comma with a new line for each person.
  Using IDLE I want to print the text file and have it listed by birth date oldest to youngest.</p>
  
  <p>I have modified this code used originally for sorting names and scores that I read on stackoverflow. However, having a date instead of a score has presented problems. I have have been reading about the datetime module and have been trying to sort based on the birthday element but I can't seem to make it work. </p>
  
  <pre><code>import datetime
  format = '%d/%m/%Y'
  
  dates = []
  with open("namedate.txt") as f:
      for line in f:
          line.strip()
          name, date = line.split(',')
          date = datetime.datetime.strptime(date, format)
          dates.append((name, date))
  
  dates.sort(key=lambda s: s[1])
  
  for name, date in dates:
      print(name, date)
  </code></pre>
  
  <p>I receive this error:</p>
  
  <pre><code>ValueError: time data ' 03/07/1960\n' does not match format '%d/%m/%Y'
  </code></pre>
  
  <p>So I need to cut the '\n' out of the birthday element but can't make it work. </p>