This may be a stupid question but..


I am trying to do something like this....

if not something and
   not somethineElse and
   not someOtherThing and
   not thisThing:
     print "asdf"

and i get an invalid syntax error. so how do you do that properly? google wasn't much help.

Recommended Answers

All 4 Replies

Relax, it's not a stupid question. Here's the proper syntax:

if not something  \
   not somethineElse and \
   not someOtherThing and \
   not thisThing:
     print "asdf"

You can use \ anywhere you need to continue a statement on the next line.

For that you could also go:

notList = ["list vars here"]
if False not in [not var for var in notList]:
   #do stuff

you can also do like this:

a=0
b=0
c=0
d=0

if not(a==0 and b==0 and c==0 and d==0):
    print "go home"
else:
    print "come here"

sweet, thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.