MCPcopy Create free account
hub / github.com/geekcomputers/Python / check_position

Function check_position

Tic-Tac-Toe Games/tic-tac-toe2.py:41–59  ·  view source on GitHub ↗

Check if the board position is empty. Args: b (List[str]): Board pos (int): Position 1-9 Returns: bool: True if empty, False if occupied. >>> b = [" "] * 10 >>> check_position(b, 1) True >>> b[1] = "X" >>> check_position(b, 1) False

(b: List[str], pos: int)

Source from the content-addressed store, hash-verified

39
40
41def check_position(b: List[str], pos: int) -> bool:
42 """
43 Check if the board position is empty.
44
45 Args:
46 b (List[str]): Board
47 pos (int): Position 1-9
48
49 Returns:
50 bool: True if empty, False if occupied.
51
52 >>> b = [" "] * 10
53 >>> check_position(b, 1)
54 True
55 >>> b[1] = "X"
56 >>> check_position(b, 1)
57 False
58 """
59 return b[pos] == " "
60
61
62def check_win() -> None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected