New to programming. How can I write this Rock, Paper, Scissors code better? I am practicing w/ Python and wanted to code a simple Rock, Paper, Scissors game w/o any user input. I used a list to hold the values and randomly pulled them with a function. I used the the return value from the first function to print the response in the second function, along with the printed results. What are some alternative methods to achieve this same functionality and make this more efficient. Thank you. 

# Internal Rock, Paper Scissors Game  &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;

import random

# List string values for the game

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


# Function to return random values from List
def game():
    return random.choice(r_p_s) + " vs. " + random.choice(r_p_s)


result = game()  # Returned Value


# Function to print out the results of the returned value with a response

def response():
    print("Roll: " + "\n" + result)

    if "Scissors vs. Paper" == result or \
       "Paper vs. Scissors" == result:
        print("\nScissors beats Paper")

    elif "Scissors vs. Rock" == result or \
         "Rock vs. Scissors" == result:
        print("\nRock beats Scissors!")

    elif "Rock vs. Paper" == result or \
         "Paper vs. Rock" == result:
        print("\nPaper beats Rock!")

    else:
        print("\nDraw! Roll again.")


response()
Despite of very simple and "verbose" initial implementation it has a bunch of issues:


r_p_s = ['Rock', 'Paper', 'Scissors'] is better defined as constant of immutable values
result is accessed within response() function body as a global variable.Instead, it's better called within the function on demand:

def response():
    result = game()
    ...

instead of arbitrary strings concatenation ... + " vs. " + ..., "Roll: " + "\n" + result - use flexible f-string formatting.
For ex.: print(f"Roll: \n{result}")
the conditions like:

if "Scissors vs. Paper" == result or \
    "Paper vs. Scissors" == result:
    print("\nScissors beats Paper")


are too verbose and hard-coded to be manageable and reliable




Now, when you realize the bad things described above and wonder if there a manageable and advanced approach - take and consider the one below, which is OOP approach representing RPSGame class (as a main class) and powered by enum classes to represent the crucial shapes.
The new implementation itself is pretty descriptive (I hope). Enjoy!

import random
from enum import Enum


class RPSGame:
    class Shape(Enum):
        R = 'Rock'
        P = 'Paper'
        S = 'Scissors'

    # winning outcome bindings
    WIN_OUTCOMES = {
        (Shape.P, Shape.R), (Shape.R, Shape.S), (Shape.S, Shape.P),
    }

    @staticmethod
    def choice():
        shapes = list(RPSGame.Shape)
        return random.choice(shapes), random.choice(shapes)

    def play(self):
        shape1, shape2 = self.choice()
        print(f"Roll: \n{shape1.value} vs {shape2.value}\n")

        if shape1 == shape2:
            print("Draw! Roll again.")
        else:
            # check to swap shapes to get winning output order
            if (shape1, shape2) not in RPSGame.WIN_OUTCOMES:
                shape1, shape2 = shape2, shape1
            print(f"{shape1.value} beats {shape2.value}!")


if __name__ == "__main__":
    rps = RPSGame()
    rps.play()
    rps.play()
    rps.play()


Sample output (from 3 plays):

Roll: 
Paper vs Scissors

Scissors beats Paper!
Roll: 
Scissors vs Scissors

Draw! Roll again.
Roll: 
Rock vs Paper

Paper beats Rock!