multi line if statement

Reply

Join Date: May 2008
Posts: 8
Reputation: nclouse is an unknown quantity at this point 
Solved Threads: 0
nclouse nclouse is offline Offline
Newbie Poster

multi line if statement

 
0
  #1
Feb 6th, 2009
This may be a stupid question but..


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

  1. if not something and
  2. not somethineElse and
  3. not someOtherThing and
  4. not thisThing:
  5. print "asdf"

and i get an invalid syntax error. so how do you do that properly? google wasn't much help.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,605
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 130
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: multi line if statement

 
0
  #2
Feb 6th, 2009
Relax, it's not a stupid question. Here's the proper syntax:

  1. if not something \
  2. not somethineElse and \
  3. not someOtherThing and \
  4. not thisThing:
  5. print "asdf"

You can use \ anywhere you need to continue a statement on the next line.
Last edited by scru; Feb 6th, 2009 at 9:59 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 901
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: multi line if statement

 
0
  #3
Feb 7th, 2009
For that you could also go:
  1. notList = ["list vars here"]
  2. if False not in [not var for var in notList]:
  3. #do stuff
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 55
Reputation: sfar_furqan is an unknown quantity at this point 
Solved Threads: 1
sfar_furqan's Avatar
sfar_furqan sfar_furqan is offline Offline
Junior Poster in Training

Re: multi line if statement

 
0
  #4
Feb 7th, 2009
you can also do like this:

  
  1. a=0
  2. b=0
  3. c=0
  4. d=0
  5.  
  6. if not(a==0 and b==0 and c==0 and d==0):
  7. print "go home"
  8. else:
  9. print "come here"
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 8
Reputation: nclouse is an unknown quantity at this point 
Solved Threads: 0
nclouse nclouse is offline Offline
Newbie Poster

Re: multi line if statement

 
0
  #5
Feb 8th, 2009
sweet, thanks for the help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC