Aug-31-2020, 06:23 PM
I have a bit of code that selects the other of two items in a list. It works fine but I'm wondering if there a more pythonic way of doing it
import random pieces = ["X", "O"] piece = random.choice(pieces) print(piece) # is there a better way to select the other item in the list opponent = pieces opponent.remove(piece) opponent = opponent[0] print(opponent)