1
+ import random
2
+ while True :
3
+ choices = ["rock" ,"paper" ,"scissors" ]
4
+ computer = random .choice (choices )
5
+ player = None
6
+
7
+ while player not in choices :
8
+ player = input ("rock, paper, scissors?:" ) .lower ()
9
+ print ("invalid choice try again!" )
10
+ if player == computer :
11
+ print ("computer: " ,computer )
12
+ print ("player: " ,player )
13
+ print ("Tie!" )
14
+
15
+ elif player == "rock" :
16
+ if computer == "paper" :
17
+ print ("computer: " , computer )
18
+ print ("player: " , player )
19
+ print ("You lose!" )
20
+ if computer == "scissors" :
21
+ print ("computer: " , computer )
22
+ print ("player: " , player )
23
+ print ("You win!" )
24
+
25
+ elif player == "scissors" :
26
+ if computer == "rock" :
27
+ print ("computer: " , computer )
28
+ print ("player: " , player )
29
+ print ("You lose!" )
30
+ if computer == "paper" :
31
+ print ("computer: " , computer )
32
+ print ("player: " , player )
33
+ print ("You won!" )
34
+
35
+ elif player == "paper" :
36
+ if computer == "scissors" :
37
+ print ("computer: " , computer )
38
+ print ("player: " , player )
39
+ print ("You lose!" )
40
+ if computer == "rock" :
41
+ print ("computer: " , computer )
42
+ print ("player: " , player )
43
+ print ("You won!" )
44
+
45
+ play_again = input ("Play again? (yes/no): " ).lower ()
46
+
47
+ if play_again != "yes" :
48
+ break
49
+
50
+ print ("Bye!" )
0 commit comments