Im new to programming and trying to build a simple rock paper scissors program in python 2.7. in my function i have 2 main if statements
rules = raw_input("Before we being playing would you like to hear the rules first? ")
if rules.lower() == "yes":
print """
Scissors cuts Paper
Paper covers Rock
Rock crushes Scissors"""
and the second
choice = raw_input("please enter your choice? (Must be either rock, paper or scissors) ")
computer = random.choice(["rock", "paper", "scissors"])
if choice == "rock" or "paper" or "scissors":
if choice == computer :
print "Its a tie !"
elif choice == "rock" and computer == "scissors":
print "Rock beats scissors you win!."
elif choice == "rock" and computer == "paper":
print "Paper beats rock you loose !."
elif choice == "paper" and computer == "scissors":
print "Scissors beats paper you loose !."
elif choice == "paper" and computer == "rock":
print "Paper beats rock you win !."
elif choice == "scissors" and computer == "paper":
print "Scissors beats paper you win !."
elif choice == "scissors" and computer == "rock":
print "Rock beats scissors you loose !."
else :
print "Invalid Entry Please try again."
individually both bits of code work as they should but when i try and put them together in one function the first if statement asking about rules works but then quits before the second if statement which has the main functionality of the program. Ive tried indenting the second bit of code within the first if statement but it doesn't seem to work
I was wondering if there is anyway of making these 2 snips of code work in a simple function ? or should i create a class with these 2 functions ? also if anyone has any tips on how to make my progam better please let me know. Thanks for any help in advance.
heres the full code
import random
def rock_paper_scissors_spock():
rules = raw_input("Before we being playing would you like to hear the rules first? ")
if rules.lower() == "yes":
print """
Scissors cuts Paper
Paper covers Rock
Rock crushes Scissors"""
choice = raw_input("please enter your choice? (Must be either rock, paper or scissors) ")
computer = random.choice(["rock", "paper", "scissors"])
if choice == "rock" or "paper" or "scissors":
if choice == computer :
print "Its a tie !":
elif choice == "rock" and computer == "scissors":
print "Rock beats scissors you win!."
elif choice == "rock" and computer == "paper":
print "Paper beats rock you loose !."
elif choice == "paper" and computer == "scissors":
print "Scissors beats paper you loose !."
elif choice == "paper" and computer == "rock":
print "Paper beats rock you win !."
elif choice == "scissors" and computer == "paper":
print "Scissors beats paper you win !."
elif choice == "scissors" and computer == "rock":
print "Rock beats scissors you loose !."
else :
print "Invalid Entry PLease try again."
rock_paper_scissors_spock()