I'm a beginner in Python and I've just finished a Rock, Paper, Scissors simulator in Python. It asks the user to enter paper, rock, or scissors and the program will generate a random number which will convert it to paper, rock or scissors. The program will then print the corresponding result. It also keeps tracks of wins/losses/ties until the user wants to stop playing then prints the prints the results back to the user.
import random as r
print("Welcome to my Rock-Paper-Scissor Game")
print("The rules are as follow:")
print(" Paper beats Rock")
print(" Rock beats Scissors")
print(" Scissors beat Paper")
print()
win=0
ties=0
loss=0
i=0
while i==0:
while True:
user=input("Do you pick Rock, Paper, or Scissors? ")
if user not in ("Scissors","scissors","paper","Paper","Rock","rock"):
print("Please enter Rock, Paper or Scissors. ")
continue
else:
break
computer=r.randint(1,3)
if computer==1:
computer="Paper"
if computer==2:
computer="Rock"
if computer==3:
computer="Scissors"
if (user=="Paper" or user=="paper"):
print("You choose paper")
if computer=="Paper":
print('\033[0;32m' + "It's a tie! The program also choose paper")
ties=ties+1
if computer=="Rock":
print('\033[1;31m' + "You won! The program choose rock")
win=win+1
if computer=="Scissors":
print('\033[1;36m' + "You lost! The program choose scissors")
loss=loss+1
if (user=="Rock" or user=="rock"):
print("You choose Rock")
if computer=="Rock":
print('\033[0;32m' + "It's a tie! The program also choose rock")
ties = ties + 1
if computer=="Scissors":
print('\033[1;31m' + "You won! The program choose scissors")
win = win + 1
if computer=="Paper":
print('\33[1;36m' + "You lost! The program choose paper")
loss = loss + 1
if (user=="Scissors" or user=="scissors"):
print("You choose Scissors")
if computer=="Scissors":
print('\033[0;32m' + "It's a tie! The program also choose scissors")
ties = ties + 1
if computer=="Paper":
print('\033[1;31m' + "You won! The program choose paper")
win = win + 1
if computer=="Rock":
print('\033[1;36m' + "You lost! The program choose rock")
loss = loss + 1
while True:
question=input('\033[0;0m' + "Would you like to play again? ")
if question not in ("Yes","yes","Y","y","no","No","n","N"):
print('\033[;1m' + "Please only enter yes or no. ")
continue
else:
break
if question in ("Yes","y","Y","yes"):
i=0
if question in ("No","n","no","N"):
i=1
print()
print("Your final results are as follows")
print("Number of wins:",win)
print("Number of ties:",ties)
print("Number of losses:",loss)