Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def roshambo():
- # nice work putting this all in a function
- game_list = ["rock", "paper", "scissors"]
- # perfect
- game_choice = random.choice(game_list)
- your_choice = input("To play Roshambo type rock, paper, or scissors: ")
- # Can you think of a way you could use a data structure to represent the relationship between rock, paper and scissors?
- # And use that data structure to cut this code in half?
- if game_choice == "rock" and your_choice == "rock":
- print("Game is a tie, try again.")
- elif game_choice == "rock" and your_choice == "paper":
- print("You win, paper covers rock.")
- elif game_choice == "rock" and your_choice == "scissors":
- print("You lose, rock crushes scissors.")
- elif game_choice == "paper" and your_choice == "paper":
- print("Game is a tie, try again.")
- elif game_choice == "paper" and your_choice == "rock":
- print("You lose, paper covers rock.")
- elif game_choice == "paper" and your_choice == "scissors":
- print("You win, scissors cut paper.")
- elif game_choice == "sissors" and your_choice == "scissors":
- print("Game is a tie, try again.")
- elif game_choice == "scissors" and your_choice == "rock":
- print("You win, rock crushes scissors.")
- elif game_choice == "scissors" and your_choice == "paper":
- print("You lose, scissors cut paper.")
- # good job handling this
- else:
- print("You did not type rock, paper, or scissors. Try again.")
- roshambo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement