I'm new to programming and I'm trying to teach myself Python through some online books.
One of the exercises has me making a Rock Paper Scissors game. The one I have written works well enough I think, but I was wondering if there were more efficient ways of writing the code, perhaps something shorter.
I'm using Python 3.4.3 IDLE GUI.
import random
#variables
done = False
comp = random.randrange(1,4)
#start
print("Lets play rock, paper, scissors! Choose numbers 1-3 only please.")
print()
#begin loop
while not(done):
#computer vs input
guess = int(input("1. Rock 2. Paper 3. Scissors "))
if comp == 1 and guess == 3:
print("Rock beats scissors, too bad!")
elif comp == 2 and guess == 1:
print("Paper beats rock, tough luck!")
elif comp == 3 and guess == 2:
print("Scissors me timbers! Scissors cuts paper! You lose.")
elif guess == 1 and comp == 3:
print("Rock beats scissors, you beat me!")
elif guess == 2 and comp == 1:
print("You win! Paper beats rock.")
elif guess == 3 and comp == 2:
print("Scissor cuts paper, you win!")
else:
print("It's a draw!")
#continue
stop = input("Do you want to quit? ")
if stop.lower() == "y" or stop.lower() == "yes":
done = True