-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrockpaper.py
More file actions
74 lines (53 loc) · 1.81 KB
/
rockpaper.py
File metadata and controls
74 lines (53 loc) · 1.81 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import random
from time import sleep
PLAYER_SCORE = 0
CPU_SCORE = 0
def game():
global PLAYER_SCORE
global CPU_SCORE
choices = ["rock", "paper", "scissors"]
player_choice = input("rock, paper or scissor? ")
while player_choice not in choices:
print("maybe choose a correct option; if you have enough braincells obviously\n")
player_choice = input("rock, paper or scissor? ")
print(f"cpu chooses...\n")
cpu_choice = random.choice(choices)
sleep(2)
print(f"{cpu_choice}\n")
sleep(1)
if player_choice == cpu_choice:
print("its a draw")
elif player_choice == "rock":
if cpu_choice == "paper":
print("haha you lose\n")
CPU_SCORE += 1
elif cpu_choice == "scissors":
print("lucky guess, you win\n")
PLAYER_SCORE +=1
elif player_choice == "paper":
if cpu_choice == "scissors":
print("haha you lose\n")
CPU_SCORE += 1
elif cpu_choice == "rock":
print("lucky guess, you win\n")
PLAYER_SCORE +=1
elif player_choice == "scissors":
if cpu_choice == "rock":
print("haha you lose\n")
CPU_SCORE += 1
elif cpu_choice == "paper":
print("lucky guess, you win\n")
PLAYER_SCORE +=1
again()
def again():
print(f"score is currently: You: {PLAYER_SCORE} - cpu: {CPU_SCORE}")
play_again = input("play again? ")
while play_again != "yes":
if play_again.lower() == "no":
print("ok see ya")
exit()
else:
print('feeling a little dumb? (it\'s "yes" or "no"...)')
play_again = input("play again? ")
game()
game()