File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ import random
2+
3+ while True :
4+
5+ user_action = input ("Rock, paper, scissors? " )
6+ possible_actions = ["rock" , "paper" , "scissors" ]
7+ computer_action = random .choice (possible_actions )
8+
9+ if user_action == computer_action :
10+ print (f'Both players selected { user_action } . Tie!' )
11+ elif user_action .lower () == "rock" :
12+ if computer_action .lower () == "scissors" :
13+ print ("Rock smashes scissors! You win!" )
14+ else :
15+ print ("Paper covers rock! You lose." )
16+ elif user_action .lower () == "paper" :
17+ if computer_action .lower () == "rock" :
18+ print ("Paper covers rock! You win!" )
19+ else :
20+ print ("Scissors cuts paper! You lose." )
21+ elif user_action .lower () == "scissors" :
22+ if computer_action .lower () == "paper" :
23+ print ("Scissors cuts paper! You win!" )
24+ else :
25+ print ("Rock smashes scissors! You lose." )
You can’t perform that action at this time.
0 commit comments