For statement


from random import randint

board =[]

for x in range(5):

def x(board):
for x in board:
print " ".join(x)


def realcol(board):
return randint(0,len(board)-1)
def realrow(board):
return randint(0,len(board)-1)

print realcol(board)
print realrow(board)

(x = realcol(board)
y = realrow(board)
print x
print y
when i assign a variable for them it worked as expected but if i code like the ones above it keep giving the output’miss’)(these words are not written in the code i’m currently running)

guesscol =int(raw_input(‘input1:’))

guessrow =int(raw_input(‘input2:’))

if guesscol == x and guessrow == y:
print ‘nice’
board[guesscol][guessrow] = ‘x’

i couldn’t understand why i need to assign a variable for the random numbers to make my guessing input match with the random answer the code above shown


Does not store anything.

is necessary to store the values for later comparison.


I see now i understand.Thanks!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.