【发布时间】:2017-07-18 21:22:45
【问题描述】:
我有一个非常基本的 Python 井字游戏。出于某种原因,当用户输入“e”时,游戏并没有退出。这是为什么呢?
import os
import sys
os.system("cls")
one = "1"
two = "2"
three = "3"
four = "4"
five = "5"
six = "6"
seven = "7"
eight = "8"
nine = "9"
selection = ""
def instructions():
print("""
Welcome to Tic-Tac-Toe!
To Play, Enter a number between 1-9 to select that space
""")
def board():
print("\t{} | {} | {}\n\t---------\n\t{} | {} | {}\n\t---------\n\t{} | {} | {}".format(one,two,three,four,five,six,seven,eight,nine))
selection = input("\nSelect a number:\n")
os.system("cls")
instructions()
while selection != "e":
board()
【问题讨论】:
标签: python tic-tac-toe