Feb-08-2023, 10:05 PM
(This post was last modified: Feb-08-2023, 10:05 PM by Gribouillis.)
You could try code like
winner = ["nobody", "computer", "player"][(self.computer_choice - self.player_choice) % 3]It can be made even shorter by using negative indexes in Python list (still assuming computer_choice and player_choice are in (0, 1, 2))
winner = ["nobody", "computer", "player"][self.computer_choice - self.player_choice]