-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRock_Paper_Scissors.py
50 lines (35 loc) · 1.41 KB
/
Rock_Paper_Scissors.py
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
import random
my_list = ['rock', 'paper', 'scissors', 'EXIT']
def Validation():
user_choice = input('Rock Paper Scissors!\n')
while user_choice not in my_list:
print("Error! Input can only be 'rock' or 'paper' or 'scissors'")
user_choice = input('Rock Paper Scissors!\n')
return user_choice
def main():
score = 0
print('Welcome to the game: Rock Paper Scissors')
print('In each round of the game you will enter your answer, rock, paper or scissors and if you win then you will gain a point.')
print('You can also exit the game by entering EXIT')
while True:
computer_choice = random.choice(my_list[0:3])
user_choice = Validation()
if user_choice == 'EXIT':
print(score)
return score
elif user_choice == computer_choice:
print('DRAW')
score += 1
elif (user_choice == my_list[0]) and (computer_choice == my_list[2]):
print('WIN')
score += 2
elif (user_choice == my_list[1]) and (computer_choice == my_list[0]):
print('WIN')
score += 2
elif (user_choice == my_list[2]) and (computer_choice == my_list[1]):
print('WIN')
score += 2
else:
print('LOSE')
if __name__ == '__main__':
main()