Advertisement
Vladkoheca

rock paper scissors.java

Mar 18th, 2025
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | Source Code | 0 0
  1. from random import *
  2.  
  3. choices = {"rock", "paper", "scissors"}
  4.  
  5. userChoice = input("Enter rock, paper or scissors: ")
  6.  
  7. if userChoice != "rock" and userChoice != "paper" and userChoice != "scissors":
  8.     print("Invalid choices! Please enter rock, paper or scissors.")
  9.  
  10. else:
  11.     computerIndex = randint(0, 2)
  12.     computerChoice = choices[computerIndex]
  13.  
  14.     print("Computer chose: " + computerChoice)
  15.  
  16. if userChoice is (computerChoice):
  17.     print("It`s a tie!")
  18.  
  19. elif userChoice is "rock" and computerChoice is "scissors" or  
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement