<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 2011/08/16 03:10 PM, Timo wrote:
    <blockquote
cite="mid:CADFAQULUWbwZrO2_W2jAKvUjxomCWHhsB2VO0eaYo8Ob4BsRrA@mail.gmail.com"
      type="cite">Hello,<br>
      Maybe a bit confusing topic title, probably the example will do.<br>
      <br>
      I have a tuple:<br>
      t = ('a', 'b', 'c', 'd')<br>
      And need the following output, list or tuple, doesn't matter:<br>
      (0, 'a', 1, 'b', 2, 'c', 3, 'd')<br>
      <br>
      I tried with zip(), but get a list of tuples, which isn't the
      desired output. Anyone with a solution or push in the right
      direction?<br>
      <br>
      Cheers,<br>
      TImo<br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Tutor maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
To unsubscribe or change subscription options:
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a></pre>
    </blockquote>
    <br>
    &gt;&gt;&gt; t = ('a', 'b', 'c', 'd')<br>
    &gt;&gt;&gt; new_t = zip(xrange(len(t)), t)<br>
    &gt;&gt;&gt; new_t<br>
    [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd')]<br>
    &gt;&gt;&gt; from itertools import chain<br>
    &gt;&gt;&gt; list(chain.from_iterable(new_t))<br>
    [0, 'a', 1, 'b', 2, 'c', 3, 'd']<br>
    <br>
    That would be for if you were using the zip way, but enumerate
    should be simpler as Martin pointed out.<br>
    <br>
    <div class="moz-signature">-- <br>
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <title>Email Signature</title>
      <style type="text/css">
p { font-size:8.5pt; font-family: Arial, Helvetica, sans-serif; color: #000;}
.subscribe {font-weight:bold; font-style:italic;}
.compuscan {color: #c60c30; letter-spacing:2px; text-transform:uppercase; font-weight:bold}
.green {color:#093;}
</style>
      <p>Christian Witts<br>
        Python Developer<br>
        <br>
        <em class="green"></em></p>
    </div>
  </body>
</html>