Alon_T
Alon_T

Reputation: 1440

Check whether a string contains a None Type value python

I am writing to a csv file in Python. But when I try to open and read it I get:

TypeError: expected string or Unicode object, NoneType found

My question is, how can I check before I write something whether my string contains a None type value.

Thanks

Upvotes: 0

Views: 1984

Answers (1)

Christian Tapia
Christian Tapia

Reputation: 34146

You can use is not (which is recommended to compare with singletons like None):

if some_string is not None:
    # write

Upvotes: 2

Related Questions