Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ex8():
- import random
- option = -1
- print("Welcome to an exciting game of rock, paper and scissors. \n0.Exit\n1. Rock\n2.Papper\n3.Scissors")
- while(option != 0):
- option = int(input(("Please enter your option: ")))
- if((type(option)!= int) or (option < 0 or option > 3)):
- print("Invalid option!")
- machine = random.randint(1,3)
- if(option == 1):
- if(machine == 1):
- print("Draw!")
- elif(machine == 2):
- print("You lost! Paper beats rock!")
- elif(machine == 3):
- print("You win! Rock beats scissors!")
- elif(option == 2):
- if(machine == 1):
- print("You win! Papper beats rock!")
- elif(machine == 2):
- print("Draw!")
- elif(machine == 3):
- print("You lose! Scissors beat paper!")
- elif(option == 3):
- if(machine == 1):
- print("You lose! Rock beats scissors!")
- elif(machine == 2):
- print("You win! Scissors beat paper")
- elif(machine == 3):
- print("Draw!")
- elif(option == 0):
- print("See you next time!")
Add Comment
Please, Sign In to add comment