Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import random
  2.  
  3. def roshambo():
  4. # nice work putting this all in a function
  5. game_list = ["rock", "paper", "scissors"]
  6. # perfect
  7. game_choice = random.choice(game_list)
  8.  
  9. your_choice = input("To play Roshambo type rock, paper, or scissors: ")
  10.  
  11. # Can you think of a way you could use a data structure to represent the relationship between rock, paper and scissors?
  12. # And use that data structure to cut this code in half?
  13. if game_choice == "rock" and your_choice == "rock":
  14. print("Game is a tie, try again.")
  15. elif game_choice == "rock" and your_choice == "paper":
  16. print("You win, paper covers rock.")
  17. elif game_choice == "rock" and your_choice == "scissors":
  18. print("You lose, rock crushes scissors.")
  19. elif game_choice == "paper" and your_choice == "paper":
  20. print("Game is a tie, try again.")
  21. elif game_choice == "paper" and your_choice == "rock":
  22. print("You lose, paper covers rock.")
  23. elif game_choice == "paper" and your_choice == "scissors":
  24. print("You win, scissors cut paper.")
  25. elif game_choice == "sissors" and your_choice == "scissors":
  26. print("Game is a tie, try again.")
  27. elif game_choice == "scissors" and your_choice == "rock":
  28. print("You win, rock crushes scissors.")
  29. elif game_choice == "scissors" and your_choice == "paper":
  30. print("You lose, scissors cut paper.")
  31. # good job handling this
  32. else:
  33. print("You did not type rock, paper, or scissors. Try again.")
  34.  
  35. roshambo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement