I have here few function from game tic-tac-toe from book python for absoulute beginners
def first():
""" Determine who goes first. Computer or Player.
"""
gofirst = raw_input("Do You want to go first? (y/n): ")
""" Determine who goes first. Computer or Player.
"""
gofirst = raw_input("Do You want to go first? (y/n): ")
if gofirst == 'y':
print "You start first"
player = X
computer = O
else:
print "Computer is first."
player = O
computer = X
return computer, player
print "You start first"
player = X
computer = O
else:
print "Computer is first."
player = O
computer = X
return computer, player
def newTable():
""" Create new table.
"""
table = []
for num in range(9):
table.append('')
return table
""" Create new table.
"""
table = []
for num in range(9):
table.append('')
return table
def playerMove(table): ## <== here
""" Get player moves
"""
move = None
while move not in legalMoves(table):
move = int(raw_input("Enter Your position? (0-9): "))
if move not in range(9):
print '\nOnly numbers 0 - 9'
elif move not in legalMoves(table):
print "\nThat position is allready occupied. Choose another: "
print "OK..."
return move
""" Get player moves
"""
move = None
while move not in legalMoves(table):
move = int(raw_input("Enter Your position? (0-9): "))
if move not in range(9):
print '\nOnly numbers 0 - 9'
elif move not in legalMoves(table):
print "\nThat position is allready occupied. Choose another: "
print "OK..."
return move
Why I have to put table in function playerMove and in some others functions?
If I dont put it's not working.
Thanks!
All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor