-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock,paper and scissors game python project.txt
More file actions
46 lines (38 loc) · 1.46 KB
/
Rock,paper and scissors game python project.txt
File metadata and controls
46 lines (38 loc) · 1.46 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
import random
choices = ["rock", "paper", "scissors"]
player_score = 0
computer_score = 0
round_number = 1
while True:
print(f"\n--- Round {round_number} ---")
computer = random.choice(choices)
player = input("Rock, paper, or scissors?: ").strip().lower()
if player not in choices:
print("Invalid input. Please choose rock, paper, or scissors.")
continue
print(f"Computer: {computer}")
print(f"Player: {player}")
if player == computer:
print("Result: It's a Tie!")
elif: (player == "rock" and computer == "scissors") or \
(player == "paper" and computer == "rock") or \
(player == "scissors" and computer == "paper"):
print("Result: You Win!")
player_score += 1
else:
print("Result: You Lose!")
computer_score += 1
print(f"Score -> You: {player_score} | Computer: {computer_score}")
play_again = input("Play another round? (yes/no): ").strip().lower()
if play_again != "yes":
print("\n--- Final Score ---")
print(f"You: {player_score} | Computer: {computer_score}")
if player_score > computer_score:
print(" Congratulations! You won the game.")
elif player_score < computer_score:
print(" You lost the game. Better luck next time!")
else:
print(" It's a tie overall!")
print("Thanks for playing!")
break
round_number += 1