-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrock_paper_game.py
45 lines (36 loc) · 1.11 KB
/
rock_paper_game.py
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
def chose():
a = ["r","p","s"]
random_a = random.choice(a)
return random_a
score = 0
count = 0
while True:
computer_choice = chose()
count = count+1
# print(chose())
user_choice = input(f"{count}.chose rock(r) paper(p) or seaser(s) or quit(q) :")
# if (user_choice != "r"):
# raise ValueError("invalid input")
# isme != worl nahi kar ra ha hai
if user_choice == "q":
break
elif count == 12:
break
elif user_choice==chose():
print("Draw")
print(f"your current score = {score}")
elif (user_choice == "p" and computer_choice == "r") or \
(user_choice == "r" and computer_choice == "s") or \
(user_choice == "s" and computer_choice == "p"):
print("You won ✔️")
score += 1
print(f"your current score = {score}")
else:
print("you loose ❌")
print(f"your current score = {score}")
if score >= 2:
print("hurray you won the match")
else:
print("ooh you loose the game ")
print(f"your total score is {score}")