Created
October 30, 2022 22:10
-
-
Save a-shebl/80caf37598c77ceaafdbfb0f2d86396f to your computer and use it in GitHub Desktop.
Xo game using dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Board_info = {"Top-L":" ","Top-M":" ","Top-R":" ", | |
"Mid-L":" ","Mid-M":" ","Mid-R":" ", | |
"Low-L":" ","Low-M":" ","Low-R":" ",} | |
def shape(board): | |
print(board["Top-L"] + "|" +board["Top-M"] +"|" +board["Top-R"]) | |
print("-----") | |
print(board["Mid-L"] + "|" +board["Mid-M"] +"|" +board["Mid-R"]) | |
print("-----") | |
print(board["Low-L"] + "|" +board["Low-M"] +"|" +board["Low-R"]) | |
turn = "x" | |
for i in range(9): | |
shape(Board_info) | |
print("Turn for " + turn) | |
move = input("which space") | |
Board_info[move] = turn | |
if turn == "x": | |
turn = "o" | |
else: | |
turn = "x" | |
if Board_info["Top-L"] and Board_info["Top-M"] and Board_info["Top-R"] == "x": | |
print("x wins") | |
elif Board_info["Mid-L"] and Board_info["Mid-M"] and Board_info["Mid-R"] == "x": | |
print("x wins") | |
elif Board_info["Low-L"] and Board_info["Low-M"] and Board_info["Low-R"] == "x": | |
print("x wins") | |
print(shape(Board_info)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment