does python have an 'or' sign?

Discussion in 'Python' started by Amber, Dec 29, 2015.

  1. Amber

    Amber

    Joined:
    Dec 29, 2015
    Messages:
    2
    Likes Received:
    0
    i'm new to python but I have programmed in JavaScript, in which there is a symbol for 'or'. is there one like that for Python that you would use in an if statement so more than one scenarios would get the same output, without making more than one if statements?
     
    Amber, Dec 29, 2015
    #1
    1. Advertisements

  2. Amber

    Joshua Ferguson Abel

    Joined:
    Jan 28, 2016
    Messages:
    5
    Likes Received:
    0

    yes python do have or conditional statement the code below is a demonstration

    mango = 1
    apple = 2
    if mango == 1 or apple == 2:
    print("yea, it worked")
    if mango == 1 or apple == 3:
    print("it worked twice")

    the output from the above will be:

    yea it worked
    it worked twice

    hope this helps.....
     
    Joshua Ferguson Abel, Jan 28, 2016
    #2
    1. Advertisements

  3. Amber

    Amber

    Joined:
    Dec 29, 2015
    Messages:
    2
    Likes Received:
    0
    thanks!
     
    Amber, Jan 28, 2016
    #3
  4. Amber

    Joshua Ferguson Abel

    Joined:
    Jan 28, 2016
    Messages:
    5
    Likes Received:
    0
    It's my pleasure....
     
    Joshua Ferguson Abel, Jan 29, 2016
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Does a resource have to have all phrases in it?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Jan 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    610
    Neil Ni
    Feb 3, 2006
  2. Jimmy
    Replies:
    1
    Views:
    1,202
    Cowboy \(Gregory A. Beamer\)
    Nov 21, 2006
  3. David T
    Replies:
    3
    Views:
    656
    Alf P. Steinbach
    Mar 8, 2009
  4. msnews.microsoft.com

    Problem with url's that don't have the "=" sign

    msnews.microsoft.com, Jan 12, 2004, in forum: ASP General
    Replies:
    5
    Views:
    317
    msnews.microsoft.com
    Jan 14, 2004
  5. Eric Boucher
    Replies:
    31
    Views:
    769
    Ross Bamford
    Mar 29, 2006
  6. Nanostuff
    Replies:
    9
    Views:
    401
    Gary Wright
    Mar 1, 2007
  7. Joshua Muheim
    Replies:
    5
    Views:
    291
    Phlip
    Aug 11, 2007
  8. Jimmy
    Replies:
    3
    Views:
    2,712
    shimmyshack
    Nov 20, 2006
Loading...