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?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
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:
    635
    Neil Ni
    Feb 3, 2006
  2. Jimmy
    Replies:
    1
    Views:
    1,236
    Cowboy \(Gregory A. Beamer\)
    Nov 21, 2006
  3. David T
    Replies:
    3
    Views:
    671
    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:
    335
    msnews.microsoft.com
    Jan 14, 2004
  5. Eric Boucher
    Replies:
    31
    Views:
    791
    Ross Bamford
    Mar 29, 2006
  6. Nanostuff
    Replies:
    9
    Views:
    444
    Gary Wright
    Mar 1, 2007
  7. Joshua Muheim
    Replies:
    5
    Views:
    320
    Phlip
    Aug 11, 2007
  8. Jimmy
    Replies:
    3
    Views:
    2,753
    shimmyshack
    Nov 20, 2006
Loading...