I've coded a simple python rock, paper, scissor game. When I input "Rock" the logic seems to respond as it should. For everything else however, I'm getting some odd behaviour, namely when I put for example:
- Me: Paper
- Comp: Scissor
I get a score of: 1, 0 respectively!
I suspect that my if-else implementation is not correct. Anyone able to help me find my error?
# module packages
import random
# data structures and primary variables
state = ["Rock", "Paper", "Scissor"]
user_points = []
computer_points = []
round_counter = 1
# user input
for i in range(3):
print("Round " + str(round_counter) + ":")
computer_choice = random.choice(state)
print("You: ", end='')
user_input = input().strip()
print("Computer: ", end='')
print(computer_choice + "\n")
# game evaluation logic
if user_input == "Rock" or "rock":
if computer_choice == "Paper":
computer_points.append(1)
elif computer_choice == "Scissor":
user_points.append(1)
elif computer_choice == user_input:
computer_points.append(0)
user_points.append(0)
elif user_input == "Paper" or "paper":
if computer_choice == "Rock":
user_points.append(1)
elif computer_choice == "Scissor":
computer_points.append(1)
elif computer_choice == user_input:
computer_points.append(0)
user_points.append(0)
elif user_input == "Scissor" or "scissor":
if computer_choice == "Paper":
user_points.append(1)
elif computer_choice == "Rock":
computer_points.append(1)
elif computer_choice == user_input:
computer_points.append(0)
user_points.append(0)
round_counter = round_counter + 1
print(user_points) # for debugging
print(computer_points) #for debugging
print("\n")
print("Your score: ", end='')
print(sum(user_points))
print("Computer score: ", end='')
print(sum(computer_points))
print("\n")
if user_points < computer_points:
print("Sorry, you lost.")
elif user_points > computer_points:
print("Congratulations, you won!")
else:
print("You drew with the computer!")