Testing for a list

Rene Pijlman reply.in at the.newsgroup
Mon Mar 10 12:35:48 EST 2003


Antun Karlovac:
>If I have 'a', I need to know whether it is a list or a string.

type(a) will tell you:

 >>> a = ['spam']
 >>> b = 'eggs'
 >>> type(a)
 <type 'list'>
 >>> type(b)
 <type 'str'>

-- 
René Pijlman




More information about the Python-list mailing list