What are the syntax for &&, ||

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RC

    #1

    What are the syntax for &&, ||


    if condition1 && condition2: # and
    doThis
    elif condition3 || condition4: # or
    doThat

    In most of language have &&, ||

    How do I do in Python?
  • Peter Otten

    #2
    Re: What are the syntax for &&, ||

    RC wrote:
    if condition1 && condition2: # and
            doThis
    elif condition3 || condition4: # or
            doThat
    In most of language have &&, ||
    >
    How do I do in Python?
    if condition1 and condition2: # &&
            doThis
    elif condition3 or condition4: # ||
            doThat

    See the pattern?

    Comment

    • Tim Chase

      #3
      Re: What are the syntax for &&, ||

      if condition1 && condition2: # and
      doThis
      elif condition3 || condition4: # or
      doThat
      >
      In most of language have &&, ||
      >
      How do I do in Python?
      Heh, you answered your own question in your comments:

      if condition1 and condition2:
      doThis()
      elif cond3 or cond4:
      doThat()

      -tkc



      Comment

      Working...