I'm in the early stages of writing a simple Tic Tac Toe game in python. I have defined 3 functions one that initializes the game, one that draws the board and one that asks if player one wants to be X or O. I feel to the best of my knowledge my functions are being requested sequentially and in proper order yet I cannot get the program to move past the first input section. Any help would be amazing.
def start():
print("Do you want to play Tic Tac Toe? Type yes or no.")
choice = input()
while choice == ('yes','no'):
if choice.lower == ('yes'):
player_choice()
elif choice.lower == ('no'):
print("goodbye")
quit()
else:
print("That was not a valid response. Type yes or no.")
start()
def drawsmall():
a = (' ___' * 3 )
b = ' '.join('||||')
print('\n'.join((a, b, a, b, a, b, a, )))
def player_choice():
print("Player one it's time to choose, X or O")
select= input()
if select.lower ==("x","o"):
print("Let the game begin.")
drawsmall()
elif select.lower != ('x','o'):
print("Please choose either X or O.")
else:
print("Come back when you're done messing around.")
quit()
Well, after figuring out what you intended, I have seen a number of things that must be changed.
First, try this and take a look:
def start():
print("Do you want to play Tic Tac Toe? Type yes or no.")
while True:
choice = input()
if choice.lower() == 'yes':
player_choice()
elif choice.lower() == 'no':
print("goodbye")
quit()
else:
print("That was not a valid response. Type yes or no.")
def drawsmall():
a = (' ___' * 3)
b = ' '.join('||||')
print('\n'.join((a, b, a, b, a, b, a,)))
def player_choice():
print("Player one it's time to choose, X or O")
select = input()
if select.lower() in ("x", "o"):
print("Let the game begin.")
drawsmall()
else:
print("Please choose either X or O.")
start()