Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I want my Python script to do something when two feature attribute values are
None
at the same time.
So I made this
if
statement:
if feature["Name"] and feature["Zon"] is None:
, but the code stops there and doesn't continue. Before the
if
statement I print both feature attribute values and get the following:
(None, None)
. So the code should theoretically work, but it doesn't. What am I missing?
You need to explicitly state the condition twice so you could use:
if feature["Name"] is None and feature["Zon"] is None:
# do something
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.