-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperScissors.py
More file actions
56 lines (54 loc) · 2.31 KB
/
RockPaperScissors.py
File metadata and controls
56 lines (54 loc) · 2.31 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
import random
#import using import RockPaperScissors or from RockPaperScissors import RCP or as Rsp
def RCP(mc, *others):
mc = mc.lower()
user = 0
comp = 0
print("Rock ⚫, Paper 📄, Scissors ✂️\n")
if mc not in ["rock", "paper", "scissors"]:
print("Invalid input, choose between rock ⚫, paper 📄 or scissors ✂️\n\nTry again\n")
RCP(input("Choose between rock ⚫, paper 📄 or scissors ✂️ : "))
cc = random.choice(["rock", "paper", "scissors"])
if mc == "rock" and cc == "scissors":
user += 1
elif mc == "paper" and cc == "rock":
user += 1
elif mc == "scissors" and cc == "paper":
user += 1
else:
comp += 1
if mc == cc:
print(f"Tie 🙃\nYour choice was: {mc}\nComputer's choice was: {cc}")
elif mc == "rock":
if cc == "scissors":
print(f"You win 🎉\nYour choice was: {mc}\nComputer's choice was: {cc}")
else:
print(f"You lose 😞\nYour choice was: {mc}\nComputer's choice was: {cc}")
print(f"\nYour score: {user}\nComputer's score: {comp}")
elif mc == "paper":
if cc == "rock":
print(f"You win 🎉\nYour choice was: {mc}\nComputer's choice was: {cc}")
else:
print(f"You lose 😞\nYour choice was: {mc}\nComputer's choice was: {cc}")
print(f"\nYour score: {user}\nComputer's score: {comp}")
elif mc == "scissors":
if cc == "paper":
print(f"You win 🎉\nYour choice was: {mc}\nComputer's choice was: {cc}")
else:
print(f"You lose 😞\nYour choice was: {mc}\nComputer's choice was: {cc}")
print(f"\nYour score: {user}\nComputer's score: {comp}")
else:
print("")
print(f"\nComputer's choice was: {cc}")
choice = ["yes", "no"]
ans = input("\nDo you want to play again? 🤔\n:")
if ans.lower() not in choice:
print("Invalid input, try again")
ans = input("\nDo you want to play again? 🤔\n:")
if ans.lower() == "yes":
mc = input("Choose between rock ⚫, paper 📄 or scissors ✂️ : ")
RCP(mc)
else:
print("\nBye 👋, thanks for playing!")
exit()
RCP(input("Choose between rock 🪨, paper 📄 or scissors ✂️ : "))