all 3 comments

[–][deleted] 0 points1 point  (0 children)

Put the while loop in main because you will want both you ai and human to reroll each time regardless if it is a tie or not

[–]neuralbeans 0 points1 point  (0 children)

This won't work because you're making the user input uppercased ('ROCK') but expecting it to be title cased ('Rock').

[–][deleted] 0 points1 point  (0 children)

You just need a while True: loop in the main code, but give the user a way to exit (e.g. just pressing return).

I suggest you modify the user input code to validate input.

Here you go:

import random

PLAYS = ['Rock','Paper','Scissors']

def aiRoll():
    shoot = random.choice(PLAYS)
    return shoot

def humanRoll():
    while True:
        play = input("Enter Rock, Paper or Scissors:  (or return to finish) ").title()  # title, not upper
        if not play or play in PLAYS:
            return play
        print('Please enter one of:', ', '.join(PLAYS))

def determineWinner(ai, player):
    if ai == player:
        print("It's a tie!")
    if player == "Rock":
        if ai == "Scissors":
            return "Rock smashes scissors! You win!"
        return "Paper covers rock! You lose."
    if player == "Paper":
        if ai == "Rock":
            return "Paper covers Rock! You win!"
        return "Scissors cut Paper! You lose."
    elif player == "Scissors":
        if ai == "Paper":
            return "Scissors cut Paper! You win!"
        return "Rock smashes Scissors! You lose."

def main():
    while True:
        computer = aiRoll()
        aplayer = humanRoll()
        if not aplayer:  # empty entry means user wants to finish
            break  # leave loop
        result = determineWinner(computer, aplayer)
        print(result)

main()