You can cut your code in half by using a dictionary to determine which choices beat which. It would look like this: # This dictionary maps each choice to the choice it can defeat win_map = { 'R': 'S', # Rock beats Scissors 'P': 'R', # Paper beats Rock 'S': 'P' # Scissors beats Paper } Then your if statements can be cut down to this: if player_choice == cpu_choice: return "It's a tie!" elif win_map[player_choice] == cpu_choice: return f'CPU wins! {player_choice} is beaten by {cpu_choice}.' else: return f'You win! {cpu_choice} is beaten by {player_choice}.' No need for all that nesting.
@AyushRai-w5c4 ай бұрын
he did do that
@DerHitsch11 ай бұрын
Thanks for the video. It would also be interesting for another part if you could show how to implement different strategies for the computer opponent. And perhaps let the different algotithms compete against each other The simplicity of the game would make it perfect for this.
@mr.RAND55842 күн бұрын
Opencv, ocr rock paper ✂️?
@gamer310taka93 ай бұрын
how do i go next in the game i pressed R but i dosent ddo anything
@DrAppalling11 ай бұрын
I used to assign this very project in my second year ECE Tools and Toys class.
@Nebuchadnezzar15019 ай бұрын
My wins losses and ties do not print... Any suggestions why?
@miauwrits11 ай бұрын
Can you make a video about how to create a personal assistant in python?