Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- game_rules = {
- "rock": ["scissors"],
- "paper": ["rock"],
- "scissors": ["paper"],
- }
- def game(user_move):
- game_moves = list(game_rules.keys())
- if user_move not in game_moves:
- return "Invalid Move"
- computer_move = game_moves[randint(0, 2)] # computer move
- print(f"{user_move=},{computer_move=}")
- if user_move == computer_move:
- return "draw"
- if computer_move in game_rules[user_move]:
- return "win"
- else:
- return "lose"
- print(game("scissors"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement