I'm trying to write a list comprehension that constructs a list of all boards that are stored (among other values) in the list in variable things.
The comprehension must work according to this specification no matter what the content of the variable things is.
# a heterogeneous list:
things = [111, board1, [1,2], board2, "a string"]
boards0 = \
[thing for thing in things if things.__class__ == ??]
The whole program is essentially a tic-tac-toe game. Boards with noughts and crosses are represented using lists. For example:
board1 = Board(
[["X","X","O"],
["X","B","O"],
["O","B","B"]])
Aucun commentaire:
Enregistrer un commentaire