Search code examples
pythontuplestic-tac-toe

call back in python Tic Tac Toe code


so I have this code right here for a tic tac toe program

def playerID():
    # asks player if want x or y
    letter = ''
    while not (letter == 'X' or letter == 'O'):
        letter = input('Do you want to be X or O?').upper()

    # first tuple is player, second is computer
    if letter == 'X':
        return ['X', 'O']
    else:
        return ['O', 'X']

and the second half of the code is

while True:
    # resets the board
    theBoard = [' '] * 10
    playerLetter, computerLetter = playerID()
    turn = playFirst()
    print('The ' + turn + ' will go first.')

it continues on after that but it's giving me two error's. I don't think it's case sensitive. I'm not so good with strings or arrays, could someone point what I'm doing wrong here?

I think this is a problem with the call back, but of course I could just be talking out of my butt.


Solution

  • you should use raw_input instead of input to get a string values in python 2.x