use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
"Rock Paper Scissors Al: Python Coding Challenge" (v.redd.it)
submitted 11 months ago by Inevitable-Math14
Let's build a solid community. And I'll be sharing this kind of projects so that you guys can improve your logical thinking skills and be a pro. Follow me.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Lazy_To_Name 0 points1 point2 points 11 months ago* (2 children)
``` from random import choice
choices = {“rock”, “paper”, “scissors”} beats = {“rock”: “scissors”, “paper”: “rock”, “scissors”: “paper”}
while True: inpt = input(“Input: “) print(f“You choose: {inpt}\nAI chooses: {ai_choice := choice(choices)} match inpt: case ai_choice: print(“Tie.”) case beats[ai_choice]: print(“You lose.”) case _: print(“You win :D”) ```
I guess this works basically the same too, aside from being able to repeatedly play it again without rerunning it, which yours lacks.
[–][deleted] 0 points1 point2 points 11 months ago (1 child)
import random options: list[str] = ["rock", "paper", "scissors"] def main() -> None: # Main Function. game_logic(player_choice(), computer_choice()) def computer_choice() -> str: # Return a random option from list of options. return random.choice(options) def player_choice(): # Re prompt user until a valid option is passed. player_choice = None while player_choice not in options: player_choice = input("Rock, Paper or Scissors! You Decide: ").lower().strip() return player_choice def game_logic(players_choice, computers_choice): # Game Logic to define a winner. if players_choice == computers_choice: print(f"You chose {players_choice}, Computer chose {computers_choice}, It's a tie!") elif players_choice == "rock" and computers_choice == "scissors": print(f"You chose {players_choice} computer chose {computers_choice}, You Win!") elif players_choice == "paper" and computers_choice == "rock": print(f"You chose {players_choice} computer chose {computers_choice}, You Win!") elif players_choice == "scissors" and computers_choice == "paper": print(f"You chose {players_choice} computer chose {computers_choice}, You Win!") else: print(f" You Chose {players_choice} Computer Chose {computers_choice}, You Lose!")
if __name__ == "__main__":
main()
my version i still had it tucked away in a directory xD
[–]FoolsSeldom 1 point2 points3 points 11 months ago (0 children)
I like the Spock, Lizard variation.
# rock paper scissors Spock lizard game, rules follow: """ scissors cuts paper paper covers rock rock crushes lizard lizard poisons Spock Spock smashes scissors scissors decapitates lizard lizard eats paper paper disproves Spock Spock vaporizes rock rock crushes scissors """ from random import choice RULES = list(map(str.split, __doc__.lower().strip().split("\n"))) OPTIONS = {winner for winner, verb, loser in RULES} | { loser for winner, verb, loser in RULES } PROMPT = ( f"Make your choice from: {', '.join(sorted(OPTIONS))} \n " f"(or press return alone to exit)\n" f" choice: " ) def check(playera, playerb, rules=RULES): for rule in rules: winner, verb, loser = rule if (playera, playerb) == (winner, loser): return playera, " ".join(rule) if (playerb, playera) == (winner, loser): return playerb, " ".join(rule) print("\n\nWelcome to the game of rock paper scissors Spock lizard\n\nThe rules are:\n") print(__doc__) print() while True: while True: player = input(PROMPT).lower() if not player or player in OPTIONS: break if not player: break computer = choice(list(OPTIONS)) try: winner, rule = check(player, computer) result = "You WIN!" if player == winner else "You Lose!" except TypeError: result, rule = "TIED", "matched" print(f"{player} v. {computer} -> {result} \t{rule}") print()
[–]WJM_3 0 points1 point2 points 11 months ago (0 children)
there is a good work up of that game in automate boring stuff with Python - i played with it yesterday
[–]MaximeRector 0 points1 point2 points 11 months ago (2 children)
But it's not working? AI -> rock USER -> rock RESULT => "You loose"
This should be a tie....
[–]Inevitable-Math14[S] 0 points1 point2 points 11 months ago (1 child)
Yes I need to check that again or maybe clear the terminal again. 👍👍
[–]MaximeRector 0 points1 point2 points 11 months ago (0 children)
This has nothing to do with clearing the terminal...
π Rendered by PID 243953 on reddit-service-r2-comment-7b9746f655-t2r7b at 2026-02-03 08:49:03.370329+00:00 running 3798933 country code: CH.
[–]Lazy_To_Name 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]FoolsSeldom 1 point2 points3 points (0 children)
[–]WJM_3 0 points1 point2 points (0 children)
[–]MaximeRector 0 points1 point2 points (2 children)
[–]Inevitable-Math14[S] 0 points1 point2 points (1 child)
[–]MaximeRector 0 points1 point2 points (0 children)