Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to run this in python 3.5.2 and I am getting the following error \'i

ID: 3574220 • Letter: I

Question

I am trying to run this in python 3.5.2 and I am getting the following error 'int' object is not callable error. Please advice in how to access the board and place the letter on it.

board=[0,1,2,3,4,5, 6,7,8,9,10, 11,12,13,14,15, 16,17,18,19,20, 21,22,23,24,25]

def show(): # This function prints out the board that it was passed.

print(' | |'' | |') print(board[1],' | ',board[2],' | ',board[3],' | ',board[4],' | ',board[5])

print(' | |'' | |')

print('------------------------------')

print(' | |'' | |')

print(board[6],' | ',board[7],' | ',board[8],' | ',board[9],' | ',board[10])

print('------------------------------')

print(' | |'' | |')

print(board[11],' | ',board[12],' | ',board[13],' | ',board[14],' | ',board[15])

print('------------------------------')

print(' | |'' | |')

print(board[16],' | ',board[17],' | ',board[18],' | ',board[19],' | ',board[20])

print('------------------------------')

print(' | |'' | |')

print(board[21],' | ',board[22],' | ',board[23],' | ',board[24],' | ',board[25]) print(' | |'' | |')

while True:

input = eval(input("Select a spot:"))

input= input

if board[input] !='x' and board [input] !='o': board[input] == 'x'

else: print( 'This spot is taken!')

show()

Explanation / Answer

Answer :

You can replace the statement :

input = eval(input("Select a spot:"))

input= input

if board[input] !='x' and board [input] !='o': board[input] == 'x'

else: print( 'This spot is taken!')

to

while True:

data = (input("Select a spot:"))

if board[data] !='x' and board [data] !='o':
    board[data] == 'x'

else:
    print( 'This spot is taken!')

As in input function works as raw_input and eval as a combination.

Other thing input keyword and function create ambiquity over here so change name to data for variation.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote