logic question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick C
    New Member
    • Apr 2007
    • 54

    logic question

    i'm having a mental block with logic statements...

    if i want to say something like

    "if a or b or c, the do X, else if d or e do Y"

    what's the syntax for getting the OR in, because just or doesn't seem to do it
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by Patrick C
    i'm having a mental block with logic statements...

    if i want to say something like

    "if a or b or c, the do X, else if d or e do Y"

    what's the syntax for getting the OR in, because just or doesn't seem to do it
    It could look like this:[code=Python]>>> a = 1
    >>> b = 0
    >>> c = 0
    >>> d = 0
    >>> e = 1
    >>> if True in [a,b,c]:
    ... print 'X'
    ...
    X
    >>> a = []
    >>> b = 'A string'
    >>> if a or b or c:
    ... print 'X'
    ...
    X
    >>> b = ''
    >>> if a or b or c:
    ... print 'X'
    ... elif d or e:
    ... print 'Y'
    ...
    Y[/code]

    Comment

    Working...