-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperSissors.py
More file actions
76 lines (54 loc) · 1.79 KB
/
Copy pathRockPaperSissors.py
File metadata and controls
76 lines (54 loc) · 1.79 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
73
74
75
76
import random
choices = ["rock", "paper", "sissors"]
def dashboard():
print("-------------------------")
print("------ Rock Paper Sissors Game ------")
print("-------------------------")
def welcome():
name = input("Enter your name: ").strip()
print(f"\nWelcome, {name}!")
print("Let's play Rock, Paper, Scissors!\n")
def game():
player_score = 0
computer_score = 0
draws = 0
while True:
play = input("Do you want to play? (y/n): ").strip().lower()
if play == "n":
print("\nThanks for playing!")
break
elif play != "y":
print("Please enter only y or n.\n")
continue
print("\nChoose:")
print("Rock")
print("Paper")
print("Scissors")
choice = input("Your choice: ").strip().lower()
if choice not in choices:
print("Invalid choice!\n")
continue
computer = random.choice(choices)
print("\nYou chose:", choice)
print("Computer chose:", computer)
if choice == computer:
print("Result: Draw!")
draws += 1
elif (
(choice == "rock" and computer == "sissors") or
(choice == "paper" and computer == "rock") or
(choice == "sissors" and computer == "paper")
):
print("Result: You Win!")
player_score += 1
else:
print("Result: Computer Wins!")
computer_score += 1
print("\n------ Scoreboard ------")
print("Player :", player_score)
print("Computer :", computer_score)
print("Draws :", draws)
print("------------------------\n")
dashboard()
welcome()
game()