I have a rock paper scissors code that works in python 2.7- it gives you 4 options (rock, paper scissors, or quit). However, I have to add a while loop to it and it somehow messes up my code whenever I add it. Can someone please help me? Thanks.
import sys
import random
import time
def main() :
tie1 = "It's a draw- you both threw rock."
tie2 = "It's a draw- you both threw paper."
tie3 = "It's a draw- you both threw scissors."
win1 = "You win! Your opponent threw scissors."
win2 = "You win! Your opponent threw rock."
win3 = "You win! Your opponent threw paper."
lose1 = "You lost. Your opponent threw paper."
lose2 = "You lost. Your opponent threw scissors."
lose3 = "You lost. Your opponent threw rock."
rand = random.randint(1,3)
print "1)rock 2)paper 3)scissors 4)quit" #1 = rock 2 = paper 3 = scissors 4 = quit
pick = raw_input ("What do you pick?: ").lower()
if pick == "rock":
if rand == (1):
print (tie1)
main()
if rand == (2):
print (lose1)
main()
if rand == (3):
print (win1)
main()
if pick == "paper":
if rand == (1):
print (win1)
main()
if rand == (2):
print (tie2)
main()
if rand == (3):
print (lose2)
main()
if pick == "scissors":
if rand == (1):
print (lose3)
main()
if rand == (2):
print (win3)
main()
if rand == (3):
print (tie3)
main()
if pick == "quit":
sys.exit (0)
main()