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

Ask a Question

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.