player = "hello"

computer_input = "bye"

counter = 5

winner = None

play_again = True

com_player = "heeeelllo"

player_score = 0

computer_score = 0


#list of items
rps = ["ROCK" , "PAPER" , "SCISSOR"]

#if player enters wrong input then ask again for input
def player_input():
    #set global varibale
    global player
    while player not in rps:
        player = input().upper()
    if player == "ROCK":
        player = "0"
        player = int(player)
    elif player == "PAPER":
        player = "1"
        player = int(player)
    elif player == "SCISSOR":
        player = "2"
        player = int(player)

def play_game():
    player_input()
    generate_computer_player()
    compare_the_players()
    #print(player)
    #print(counter)
    print(com_player)
    display_winner()

#computer randomly generates on input
def generate_computer_player():
    #set global variable
    global counter , com_player
    from random import randint
    counter = randint(0,2)
    if counter == 0:
        com_player = "ROCK"
    elif counter == 1:
        com_player = "PAPER"
    else:
        com_player = "SCISSOR"

def compare_the_players():
    #set global variables
    global winner, counter
    if player == 0:
        if counter == 0:
            winner = "Tie"
        elif counter == 1:
            winner = "COMPUTER wins"
        elif counter == 2:
            winner = "PLAYER wins"
    elif player == 1:
        if counter == 0:
            winner = "PLAYER wins"
        elif counter == 1:
            winner = "Tie"
        elif counter == 2:
            winner = "COMPUTER wins"
    elif player == 2:
        if counter == 0:
            winner = "COMPUTER wins"
        elif counter == 1:
            winner = "PLAYER wins"
        elif counter == 2:
            winner = "Tie"

def display_winner():
    global player_score , computer_score
    print(winner)
    if winner == "PLAYER wins":
        player_score += 1
    elif winner == "COMPUTER wins":
        computer_score += 1

response = ["Yes" , "No"]




#actual game begins here
#ask player if he/she wants to play again
#for that using while loop
while play_again:
    play_game()
    while play_again not in response:
        #ask player
        play_again = input("\n\nwant to play again?\n").capitalize()
    #if player says yes set 'play_again' as true
    if play_again == "Yes":
        play_again = True
    #else set 'play_again' as false
    else:
        play_again = False
print("\nYour score = " , player_score , "\nComputer's score = " , computer_score)
if player_score > computer_score:
    print("You won")
elif player_score < computer_score:
    print("You lose")
else:
    print("Tie")
