-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathR_P_S_game.py
More file actions
45 lines (30 loc) · 2.06 KB
/
Copy pathR_P_S_game.py
File metadata and controls
45 lines (30 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import random
options = ["Rock", "Paper", "Scissors"]
# options for the game
player = False #sets player to False
print("You can type stop to terminate the program")
#The program can be stopped by typing stop.
while player == False: # While loop will take place as long as player is False
opponent = options[random.randint(0,2)] # Sets a random value for opponent between 0,1,2 that then pulls the respective item from the list in order 0= Rock ect.
player = input("Pick: Rock, Paper, Scissors?") # Asks player to choose / input option
if player == opponent: # If the player and opponent are the same then no winner is declared
print("No Winner, Try again.")
elif player == "Rock": # If player chooses Rock
if opponent == "Paper": # Paper will declare the player the loser of the round
print("You lose,", opponent, "beats", player)
else:# Or they are the winner
print("You win,", player, "beats", opponent)
elif player == "Paper": # Player picked Paper
if opponent == "Scissors": # Scissors ends the round with the opponent winning
print("You lose,", opponent, "beats", player)
else:# If not Rock must have been picked by the oppenend and the player wins
print("You win,", player, "beats", opponent)
elif player == "Scissors":# Same with player picking Scissors
if opponent == "Rock": # Rock for the opponent wins them the round
print("You lose,", opponent, "beats", player)
else:# Or the player wins
print("You win,", player, "beats", opponent)
elif player == "stop": break # if the player opts to stop the program will stop at this point
else: # If nothing above is triggered properly then the player misspelled the word, or did not pick a correct choice and the message bellow is displayed.
print("Input not valid. Make sure your selection was capitalized.")
player = False # Sets player back to False, to properly restart loop and continue the game