Finding sublists inside lists <p>I have a list that may or may not contain sublists as elements, and I need to check whether an element is or is not a sublist.</p> <p>For example consider</p> <pre><code>&gt;&gt;&gt; list = ['a', 'b', 'c', ['d', 'e'] ] </code></pre> <p>As I would expect, I get</p> <pre><code>&gt;&gt;&gt; list[2] 'c' &gt;&gt;&gt; list[3] ['d', 'e'] &gt;&gt;&gt; list[3][1] 'e' </code></pre> <p>and</p> <pre><code>&gt;&gt;&gt; len(list[1]) 1 &gt;&gt;&gt; len(list[3]) 2 </code></pre> <p>and also</p> <pre><code>&gt;&gt;&gt; type(list[1]) &lt;type 'str'&gt; &gt;&gt;&gt; type(list[3]) &lt;type 'list'&gt; </code></pre> <p>So far so good. However, quite surprisingly (at least for a python novice as I am)</p> <pre><code>&gt;&gt;&gt; type(list[1]) is list False &gt;&gt;&gt; type(list[3]) is list False </code></pre> <p>Could somebody explain this? Clearly I can just use <code>len()</code> to determine whether an element is a sublist, but I think the explicit type checking should be more appropriate, as it is a more precise statement of what I want to do. Thanks. </p>