title: Python key exists: Key is a tuple of integer and string
body: <p>I have a python dictionary that I have build where its key is a tuple and values are in a list. Tuple contains integer and string. To best describe here is a simple example:</p>
  
  <pre><code>&gt;&gt;&gt; x = {(1, 'test'): ['marry', 'tom']}
  </code></pre>
  
  <p>I want to build a logic if first element of the tuple in the dictionary key exist do my logic:</p>
  
  <p>so I tried following:</p>
  
  <pre><code>&gt;&gt;&gt; if 1 in x:
  ...     print x
  ... 
  </code></pre>
  
  <p>and it didn't work.</p>
  
  <p>But then i did the following to test if in function work when the key is not a tuple and it does:</p>
  
  <pre><code>&gt;&gt;&gt; y = {}
  &gt;&gt;&gt; y[1] = []
  &gt;&gt;&gt; y[1].append("tom")
  &gt;&gt;&gt; if 1 in y:
  ...     print y
  ... 
  {1: ['tom']}
  </code></pre>
  
  <p>How can check if the key exist in a dictionary if key happened to be first element of a tuple.</p>