How can I verify if the content of a variable is a list or a string?

Chris Angelico rosuav at
Wed Feb 1 10:48:50 CET 2012

On Wed, Feb 1, 2012 at 12:11 PM, Andres Soto <soto_andres at> wrote:
> okok, my mistake is that I was using string in place of str. Thank you!!
> regards

Tip: In the interactive interpreter, enter:

>>> type("spam")
<class 'str'>

In Python 2, it'll say "type" not "class", but same diff. It tells you
there what the type is.

Same can be used for any other literal, name, or other object. Can be
quite handy at times.


More information about the Python-list mailing list