Created
January 5, 2016 05:33
-
-
Save libert-xyz/9a5aa691df1dd33ba78a to your computer and use it in GitHub Desktop.
Rock Paper Scissors - Exercise (http://www.practicepython.org/exercise/2014/03/26/08-rock-paper-scissors.html)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def start_again(): | |
print("Invalid Input") | |
lets_play() | |
def play_again(): | |
choose = str(input("Wanna play again? Yes[y] - No[n] --> ")) | |
if choose.lower() == 'y': | |
lets_play() | |
else: | |
print ("That means NO") | |
print ("********************************") | |
print ("Thank's 4 playing. See you soon") | |
def lets_play(): | |
choose = str(input("Rock[r] Paper[p] or Scissors[s]? --> ")) | |
options=['r','p','s'] | |
if choose.lower() not in options: | |
start_again() | |
else: | |
robot = random.randint(0,2) | |
if choose.lower() == 'r' and options[robot] == 's': | |
print ("**You Win!, Rock beats Scissors**") | |
play_again() | |
elif choose.lower() == 's' and options[robot] == 'p': | |
print ("**You Win!, Scissors beats paper**") | |
play_again() | |
elif choose.lower() == 'p' and options[robot] == 'r': | |
print ("**You Win, Paper beats rock**") | |
play_again() | |
#User lost | |
elif options[robot] == 'r' and choose.lower() == 's': | |
print ("**You Lost, Rock beats Scissors**") | |
play_again() | |
elif options[robot] == 's' and choose.lower() == 'p': | |
print ("**You Lost, Scissors beats paper**") | |
play_again() | |
elif options[robot] == 'p' and choose.lower() == 'r': | |
print ("**You Lost, Paper beats rock**") | |
play_again() | |
else: | |
print ("**Tie, robot also choose %s **" %(options[robot])) | |
play_again() | |
lets_play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wow, detailed program, but i think u can simplify it a bit, and i wish i could know wt computer used!