0

EDIT:

I now realise that this was a bit of a duplicate but user2314737 's answer did help because there was an issue with operator precedence, so I will leave the question up in case it helps someone in the future.

I am currently trying to program a Rock, Paper, Scissors game in Python. The problem I am faced with, is that when I win, the score doesn't seem to change, and when I do win, the computer still says I have lost. Here is my code:

print("Welcome to my Rock, Paper, Scissors! game. Its quite simple. 'R' = Rock, 'P' = Paper and 'S' = Scissors. All of your inputs must begin with a capital letter. Good luck! Here we go!")
import random
Computer_RPS = ["Rock", "Paper", "Scissors"]

def RPS():
    Cpoints = 0
    Upoints = 0
    one = 1
    User_choice1 = input("Rock, Paper, Scissors!...")
    Computer_choice1 = (random.choice(Computer_RPS))
    """
    while (User_choice1 != "Rock" or "Paper" or "Scissors" or "R" or "P" or "S"):
        User_choice1 = input("That value is not valid. Lets try again; Rock, Paper, Scissors!...")
    """
    if User_choice1 == Computer_choice1:
        print("Draw. Getting tense!...")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Rock" and User_choice1 == "S" or "Scissors":
        (Cpoints) + (one)
        print("Good try. Better luck next time!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Paper" and User_choice1 == "R" or "Rock":
        (Cpoints) + (one)
        print("Unlucky. But that means 1 point to me!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Scissors" and User_choice1 == "P" or "Paper":
        (Cpoints) + (one)
        print("Unlucky. But that means 1 point to me!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    else:
        print("Well Done! You beat me.  :'-(   Never mind. One point to you.")
        Upoints += 1
    
RPS()
RPS()
RPS()

and here is a screen-shot of my code and the output of it: My code and its output.

Any help will be greatly appreciated by me. Thank you for even just taking your time to read my question.

Kiran
  • 117
  • 3
  • 10

1 Answers1

2

You have an issue with operators precedence. Consider this:

a=1

if a==3 or 4:
    print("a is equal to 3 or four")
Graham
  • 7,431
  • 18
  • 59
  • 84
user2314737
  • 27,088
  • 20
  • 102
  • 114