from random import randint
#from os import system
from IPython.display import clear_output
choices = ["ROCK", "PAPER", "SCISSORS"]
computerName = "Digitron 5000"
userName = input("What's your name? ==> ")
userScore = 0
computScore = 0
def endgame():
print("{} = {} --- {} = {}".format(computerName, computScore, userName, userScore))
print("Go again? Y or N")
answer = input("==> ") #input asking to go again.
if answer == "Y" or answer == "y": # if yes I rerun the main() function
#system("clear")
clear_output()
main()
elif answer == "N" or answer == "n": #if no I print have a nice day and leave
clear_output()
print("")
if computScore > userScore:
print("{} Wins".format(computerName))
elif computScore < userScore:
print("{} Wins".format(userName))
else:
print("{} is as good as {}, It was a tie with {} wins each!!!!".format(userName, computerName, userScore))
else: #if it's not a 'y', 'Y', 'n', or 'N' I rerun the function
endgame()
def main():
global userScore, computScore
computerChoice = choices[randint(0,2)]
print("Choose one of the following\nSee if you can beat the computer.")
print("1. ROCK")
print("2. PAPER")
print("3. SCISSORS")
userChoose = int(input("Make your choice 1, 2, or 3 => ")) - 1
userChoice = choices[userChoose]
print("{} chose {}".format(userName, userChoice))
print("{} chose {}".format(computerName, computerChoice))
if userChoice == computerChoice:
print("TIE!")
endgame()
elif userChoice == "ROCK":
if computerChoice == "SCISSORS":
print("{} Wins!".format(userName))
userScore += 1
endgame()
else:
print("{} Wins!".format(computerName))
computScore += 1
endgame()
elif userChoice == "SCISSORS":
if computerChoice == "PAPER":
print("{} Wins!".format(userName))
userScore += 1
endgame()
else:
print("{} Wins!".format(computerName))
computScore += 1
endgame()
elif userChoice == "PAPER":
if computerChoice == "ROCK":
print("{} Wins!".format(userName))
userScore += 1
endgame()
else:
print("{} Wins!".format(computerName))
computScore += 1
endgame()
else:
endgame()
print("Hi {}, I am the DIGITRON 5000 R.P.S. SUPER COMPUTER".format(userName))
main()