-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (33 loc) · 1.25 KB
/
main.py
File metadata and controls
41 lines (33 loc) · 1.25 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
# WELCOME TO ROCK PAPER SCISSOR THE GAME
# 1 --ROCK
# 0 --PAPER
# -1 --SCISSOR
import random
import os
os.system('cls')
yourDict = {"rock": 1, "paper": 0, "scissor": -1, "scissors": -1}
reverseDICT = {1: "rock", 0: "paper", -1: "scissor"}
print("\033[1;3;32m WELCOME TO ROCK PAPER SCISSOR THE GAME :--\033[0m")
print("Choices: rock / paper / scissor")
while True:
yourstr = input("Please enter your choice: ").strip().lower()
if yourstr not in yourDict:
print("Invalid choice. Try again.")
continue
you = yourDict[yourstr]
COMPUTER = random.choice([1, 0, -1])
comp_str = reverseDICT[COMPUTER]
print("")
print("\033[1;3;32m COMPUTER : ROCK, PAPER, SCISSOR ....!\033[0m")
print("")
print(f"you chose \033[1;3;32m '{yourstr.upper()}'\033[0m and computer chose \033[1;3;32m'{comp_str.upper()}'\033[0m THEN :")
if you == COMPUTER:
print("IT'S A DRAW 🫥")
elif (you == 1 and COMPUTER == -1) or (you == 0 and COMPUTER == 1) or (you == -1 and COMPUTER == 0):
print("YOU WIN 😍")
else:
print("YOU LOSE ! 😒")
again = input("Play again? (Y/N): ").strip().lower()
if again != "y":
print("Thanks for playing. Goodbye!")
break