Hello All,
I have the code below that I used to create a simple tic tac toe game for
class. I am learning Python but have programmed in C+ before so I brought
over a lambda and found that it worked in Python. Unfortunately I don't
think my classmates will understand the use of lambda here but I am having
are hard time converting that to strictly python.
Let me know if it can be done.
Thanks
from tkinter import *
def ttt(r,c):
global player
if player == 'X':
b[r][c].configure(text = 'X')
player = 'O'
else:
b[r][c].configure(text = 'O')
player = 'X'
root = Tk()
b = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
for i in range(3):
for j in range(3):
b[i][j] = Button(font=('Aerial', 56), width=3, bg='yellow',
command = lambda r=i,c=j: ttt(r,c))
b[i][j].grid(row = i, column = j)
player = 'X'
mainloop()
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor