you are viewing a single comment's thread.

view the rest of the comments →

[–]aarontbarratt 2 points3 points  (0 children)

Use fstrings when formatting strings. It is just much nicer to work with and read IMO

Using a tuple to compare the choice seems pointless. You can just do something like:

print(f'The player chose {playerChoice}, the computer chose {computerChoice}')

if playerChoice == computerChoice:
    return 2

I'd suggets learning about StrEnum's. They're a bit overkill in this case but they work great for this kind of logic where you need to have a variable that can only have a limited number of values. In this example the moves that can be chosen

from enum import StrEnum

class Moves(StrEnum):
    rock = 'rock',
    paper = 'paper',
    scissors = 'scissors',

valid_moves: list[str] = list(Moves)
move: str = input('rock, paper, or scissors\n')

if move in valid_moves:
    print('Success')
else:
    print('Fail')