title: Python: Converting ('Monday', 'Tuesday', 'Wednesday') to 'Monday to Wednesday'
body: <p>I'm getting a sequence of day of the week. Python code of what I want to do:</p>
  
  <pre><code>def week_days_to_string(week_days):
      """
      &gt;&gt;&gt; week_days_to_string(('Sunday', 'Monday', 'Tuesday'))
      'Sunday to Tuesday'
      &gt;&gt;&gt; week_days_to_string(('Monday', 'Wednesday'))
      'Monday and Wednesday'
      &gt;&gt;&gt; week_days_to_string(('Sunday', 'Wednesday', 'Thursday'))
      'Sunday, Wednesday, Thursday'
      """
      if len(week_days) == 2:
         return '%s and %s' % weekdays
      elif week_days_consecutive(week_days):
         return '%s to %s' % (week_days[0], week_days[-1])
      return ', '.join(week_days)
  </code></pre>
  
  <p>I just need the <code>week_days_consecutive</code> function (the hard part heh).</p>
  
  <p>Any ideas how I could make this happen?</p>
  
  <p><strong>Clarification:</strong></p>
  
  <p>My wording and examples caused some confusion. I do not only want to limit this function to the work week. I want to consider all days of the week (S, M, T, W, T, F). My apologies for not being clear about that last night. Edited the body of the question to make it clearer.</p>
  
  <p><strong>Edit: Throwing some wrenches into it</strong></p>
  
  <p>Wraparound sequence:</p>
  
  <pre><code>&gt;&gt;&gt; week_days_to_string(('Sunday', 'Monday', 'Tuesday', 'Saturday'))
  'Saturday to Tuesday'
  </code></pre>
  
  <p>And, per @user470379 and optional:</p>
  
  <pre><code>&gt;&gt;&gt; week_days_to_string(('Monday, 'Wednesday', 'Thursday', 'Friday'))
  'Monday, Wednesday to Friday'
  </code></pre>