-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockPaperSicssor.py
65 lines (63 loc) · 2.61 KB
/
RockPaperSicssor.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import random
chance = 10
while True:
print('''Welcome Rock Paper Scissor game.
You have to type 'p' for paper,
's' for Scissor and 'r' for rock.
There will be total of 10 rounds and results will be displayed.
Type "exit" if you want to terminate the game\v''')
li = ["r", "p", "s"]
comp_points = 0
usr_points = 0
i = 0
while i < chance:
usr_choice = input("'p' or 's' or 'r' ?\n>>").lower()
rand = random.choice(li)
if usr_choice in li or "exit":
if usr_choice == rand:
print(f"Draw.\t\t{9-i} rounds left\n")
i = i + 1
elif usr_choice == "r" and rand == "p":
print(f"Computer +1 point.\t\t{9-i} rounds left\n")
i = i + 1
comp_points = comp_points + 1
elif usr_choice == "r" and rand == "s":
print(f"User +1 point.\t\t{9-i} rounds left\n")
i = i + 1
usr_points = usr_points + 1
elif usr_choice == "p" and rand == "r":
print(f"User +1 point.\t\t{9-i} rounds left\n")
i = i + 1
usr_points = usr_points + 1
elif usr_choice == "p" and rand == "s":
print(f"Computer +1 point.\t\t{9-i} rounds left\n")
i = i + 1
comp_points = comp_points + 1
elif usr_choice == "s" and rand == "p":
print(f"User +1 point.\t\t{9-i} rounds left\n")
i = i + 1
usr_points = usr_points + 1
elif usr_choice == "s" and rand == "r":
print(f"Computer +1 point\t\t{9 - i} rounds left\n")
i = i + 1
comp_points = comp_points + 1
# else:
# break
else:
print('''no command exist. You have to type 'p' for paper,
's' for Scissor and 'r' for rock. To terminate type 'exit'.''')
continue
if i == 10:
print("Game Completed.")
if usr_points > comp_points:
print(f"Congratulation you won\n Your point: {usr_points}\nComputer points:{comp_points}")
elif usr_points == comp_points:
print(f"Game Draw!\nYour point: {usr_points}\nComputer points:{comp_points}")
else:
print(f"Sorry you lose.\nYour point: {usr_points}\nComputer points:{comp_points}")
conti = input("Do you want to continue?('y' for yes)").lower()
if conti == "y":
i = 0
continue
else:
break