How to check if a string is empty in python?

John Salerno johnjsal at NOSPAMgmail.com
Thu May 3 15:03:38 EDT 2007


mensanator at aol.com wrote:
> On May 2, 3:49 pm, Basilisk96 <basilis... at gmail.com> wrote:
>> A simple
>>
>> if s:
>>     print "not empty"
>> else:
>>     print "empty"
>>
>> will do.
> 
> How do you know that s is a string?

Seems like a fair assumption given the OP's question and example.



More information about the Python-list mailing list