-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRock-Paper-Scissors Game
32 lines (26 loc) · 1.01 KB
/
Rock-Paper-Scissors Game
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
import random
def determine_winner(user_choice, computer_choice):
if user_choice == computer_choice:
return "It's Tie!"
elif (user_choice == 'rock' and computer_choice == 'scissors') or \
(user_choice == 'paper' and computer_choice == 'rock') or \
(user_choice == 'scissors' and computer_choice == 'paper'):
return "You win!"
else:
return "Computer wins!"
def play_game():
user_choice = input("Enter your choice (rock, paper, scissors): ").lower()
computer_choice = random.choice(['rock', 'paper', 'scissors'])
print(f"Your choice: {user_choice}")
print(f"Computer's choice: {computer_choice}")
result = determine_winner(user_choice, computer_choice)
print(result)
def main():
while True:
play_game()
play_again = input("Do you want to continue? (yes/no): ").lower()
if play_again != 'yes':
print("Thanks for playing!")
break
if __name__ == "__main__":
main()