-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeunP5.py
More file actions
64 lines (55 loc) · 3.08 KB
/
Copy pathSeunP5.py
File metadata and controls
64 lines (55 loc) · 3.08 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
#SeunP5.py
#Programmer: Seun Ajayi
#Purpose: To play the game rock, paper, scissors
import random
#Create the list
computerScore = userScore = 0
choices=['rock','paper','scissors']
print("Welcome to the rock, paper, scissors game.")
gameContinue = True
#Ends game if user enters no
while gameContinue:
#Breaks loop if any player won twice
while computerScore < 2 and userScore < 2:
userInput = input("\nPlease select \"rock\", \"paper\", or \"scissors\" : ").lower()
compChoice = random.randint(0,2)
#Check for winner and increment their score
if choices[compChoice] == userInput:
print("It's a Tie!")
elif choices[compChoice] == "rock" and userInput == "paper":
userScore +=1
print(f"You won! - {userInput} covers {choices[compChoice]}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You won that round; The game's score is: {userScore} - {computerScore}.\n")
elif choices[compChoice] == "rock" and userInput == "scissors":
computerScore +=1
print(f"You lost! - {choices[compChoice]} knocks {userInput}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You lost that round; The game's score is: {userScore} - {computerScore}.\n")
elif choices[compChoice] == "paper" and userInput == "rock":
computerScore +=1
print(f"You lost! - {choices[compChoice]} covers {userInput}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You lost that round; The game's score is: {userScore} - {computerScore}.\n")
elif choices[compChoice] == "paper" and userInput == "scissors":
userScore +=1
print(f"You won! - {userInput} cuts {choices[compChoice]}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You won that round; The game's score is: {userScore} - {computerScore}.\n")
elif choices[compChoice] == "scissors" and userInput == "rock":
userScore +=1
print(f"You won! - {userInput} knocks {choices[compChoice]}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You won that round; The game's score is: {userScore} - {computerScore}.\n")
else:
computerScore +=1
print(f"You lost! - {choices[compChoice]} cuts {userInput}")
print(f"You selected: {userInput}; the computer selected: {choices[compChoice]}")
print(f"You lost that round; The game's score is: {userScore} - {computerScore}.\n")
#Breaks loop when player enters no
choice = input("Do you want to play another round of rock, paper, scissors? (yes/no): ").lower()
if choice == "no":
gameContinue = False
else:
computerScore = userScore = 0
print("Thank you for playing rock, paper, and scissors.")