gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
give me a python code for rock paper sisccor game
- User
give me a python code for rock paper sisccor game
- Assistant
Sure! Here's a simple code for a rock-paper-scissors game using Python:
import random def play(): user = input("Enter your choice (rock/paper/scissors): ") computer = random.choice(['rock', 'paper', 'scissors']) print("You chose:", user) print("Computer chose:", computer) if user == computer: return "It's a tie!" elif (user == 'rock' and computer == 'scissors') or (user == 'paper' and computer == 'rock') or (user == 'scissors' and computer == 'paper'): return "You win!" else: return "Computer wins!" print(play())To play the game, simply run the code. The user will be prompted to enter their choice, and the computer will randomly select one of the choices. The result will be printed on the screen.