How to check if a list contains a string
<p>I need to iterate through a list and check if the value is a string or an int. Is there any easy way to do this in python?</p>

<p>For example:</p>

<p><code>[1,2,3]</code> would be true.</p>

<p><code>["a",2,3]</code> would be false.</p>

<p>Assuming you meant that you need to check through all the values of the list and that only if they were all integers the function would return True, this is how I'd do it:</p>

<pre><code>def test(list):
    result=True
    for elem in list:
        if type(elem)!=int:
            result=False
    return result
</code></pre>

python list