title: Printing a Python list with hex elements
body: <p>I have this list:</p>
  
  <pre><code>a_list = [0x00, 0x00, 0x00, 0x00]
  </code></pre>
  
  <p>When I print it, I get:</p>
  
  <pre><code>print a_list
  [0, 0, 0, 0]
  </code></pre>
  
  <p>But I want:<code>[0x0, 0x0, 0x0, 0x0]</code> or <code>[0x00, 0x00, 0x00, 0x00]</code>, it doesn't matter for now.</p>
  
  <p>I've tried to create a function such as:</p>
  
  <pre><code>def hex_print(the_list):
       string = '['
       for element in the_list:
           if(the_list.index(element) &lt; len(the_list)):
               print(str(the_list.index(element)))
               string = string + hex(element) + ', '
           else:
               print(str(the_list.index(element)))
               string = string + hex(element) + ']'
       print string
  </code></pre>
  
  <p>But every time the printed message is:</p>
  
  <pre><code>[0x0, 0x0, 0x0, 0x0,
  </code></pre>
  
  <p>I think that the_list.index(element) always returns the first occurrence of element in the_list and not the actual position of the element. Is there a way where I can get the actual position of the element?</p>