Everytime I run my code only the 2nd boolean is run even though it should test for all options then run that one. When I run this code:
import random
Player_Score = 0
Computer_Score = 0
while Player_Score < 5 or Computer_Score < 5:
Player_object = input("Would you like to choose R, P, or S?")
Computer_object = random.sample(set(["R", "P", "S"]), 1)
if Player_object == "R" or "r":
if Computer_object == "R":
print("You have chosen " +Player_object+ " and the Computer chose " +str(Computer_object)+ ".You have tied with the Computer and neither of you have scored a point.")
elif Computer_object == "P":
Computer_Score = Computer_Score + 1
print("You have chosen " +Player_object+ " and the Computer chose " +str(Computer_object)+ ". You have been beaten by the Computer and it has scored a point.")
else:
Player_Score == Player_Score + 1
print("You have chosen " +Player_object+ " and the Computer chose " +str(Computer_object)+ ".You have beaten the Computer scored a point.")
I end up with results like:
You have chosen R and the Computer chose ['S'].You have beaten the Computer scored a point.
Would you like to choose R, P, or S?R
You have chosen R and the Computer chose ['P'].You have beaten the Computer scored a point.
Would you like to choose R, P, or S?R
You have chosen R and the Computer chose ['S'].You have beaten the Computer scored a point.
Would you like to choose R, P, or S?R
You have chosen R and the Computer chose ['R'].You have beaten the Computer scored a point.
Would you like to choose R, P, or S?R
You have chosen R and the Computer chose ['P'].You have beaten the Computer scored a point.
So is there a way to fix this, because at this point I don't know what to do to fix this.