[Tutor] function arg
josip
josipl2000 at yahoo.com
Fri Aug 25 18:17:50 CEST 2006
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): ")
if gofirst == 'y':
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
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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060825/5a7a348f/attachment.html
More information about the Tutor
mailing list