Files
Python-Course/wip_rock-paper-scissors.py

66 lines
2.0 KiB
Python

#############################################
# #
# Work in progress!! #
# #
#############################################
import random
import sys
import time
losses = 0
wins = 0
ties = 0
while True:
# Computer choice:
computer_choice = random.randint(1,3)
if computer_choice == 1:
computer_choice = 'Paper'
elif computer_choice == 2:
computer_choice = 'Rock'
elif computer_choice == 3:
computer_choice = 'Scissors'
# Player choice:
player_choice = input('What do you choose? Rock(R), Paper(P), or Scissors(S)?\n>')
if player_choice == 'P':
player_choice = 'Paper'
elif player_choice == 'R':
player_choice = 'Rock'
elif player_choice == 'S':
player_choice = 'Scissors'
else:
print(f'The choice you made ("{player_choice}") is not valid. The program will now exit')
sys.exit()
# Playing the game:
if computer_choice == player_choice:
print('It is a tie!')
ties += 1
elif computer_choice == 'Rock':
if player_choice == 'Scissors':
print('You lost, you chose Scissors and the computer chose rock!')
losses += 1
elif player_choice == 'Paper':
print('You won, you chose scissors and the computer chose rock!')
wins += 1
elif computer_choice == 'Paper':
if player_choice == 'Scissors':
print('You won, you chose Scissors and the computer chose paper!')
wins += 1
elif player_choice == 'Rock':
print('You lost, you chose rock and the computer chose paper!')
losses += 1
elif computer_choice == 'Scissors':
if player_choice == 'Paper':
print('You lost, computer chose scissors and you chose paper!')
losses += 1
elif player_choice == 'Rock':
print('You won, computer chose scissors and you chose rock!')
wins += 1