Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Rock Paper Scissors with Lizard Spock Extension (but with Wizard in place of Spock)
- # By Mike Kerry - Jan 2021 - Email: acclivity2@gmail.com
- import random
- mydict = {"R": "Rock", "P": "Paper", "S": "Scissors", "L": "Lizard", "W": "Wizard", "Q": "Quit"}
- winners = ["RS", "PR", "SP", "LW", "WS", "RL", "SL", "LP", "PW", "WR"] # winning pairs. Rock beats Scissors etc.
- scores = [0,0] # List for keeping scores
- while True:
- comp = random.choice(winners)[0] # Computer makes a random choice
- while True:
- user = input("=" * 20 + "\nMake your choice, Rock, Paper, Scissors, Lizard or Wizard (initial will do)\ntype Q to quit: ")
- user = user[0].upper()
- if user in mydict: # Validate user input first letter for R P S L W or Q only
- break
- print("Invalid. Try again")
- if user == "Q": # Q = Quit
- break
- print("You chose:", mydict[user], "\nThe computer chose", mydict[comp])
- if comp == user: # Did the user choose same as computer?
- print("It was a tie!")
- else:
- if comp + user in winners: # Check for computer winning
- print("You lose!")
- scores[1] += 1 # count 1 computer win
- else: # Otherwise user won
- print("You won!")
- scores[0] += 1 # count 1 user win
- print("Final scores: (You, computer)", *scores)
Add Comment
Please, Sign In to add comment