Member Avatar for HTMLperson5

Hi, everyone. I am making a tic - tac - toe game and I am having some trouble.
As you can see I have made good progress:

from os import system
a = "1"; b = "2"; c = "3"; d = "4"; e = "5"; f = "6"; g = "7"; h = "8"; i = "9";
while True:
    system("cls") #OS code, for linux change to "clear"
    print a, b, c,"\n", d , e, f,"\n", g, h, i
    u = raw_input('Enter number [X]  ')
    if u == "1":
        a = "x"
    if u == "2":
        b = "x"
    if u == "3":
        c = "x"
    if u == "4":
        d = "x"
    if u == "5":
        e = "x"
    if u == "6":
        f = "x"
    if u == "7":
        g = "x"
    if u == "8":
        h = "x"
    if u == "9":
        i = "x"
    else:
        print "Please enter a valid number."

I haven't got round to giving player O a turn yet, but I think I have gotten off to a bad start
:(
Because now, I don't know how to continue or how the program will detect if one player has won (with 3 in a row).

search tic tac toe python in daniweb search or browse the Code Snippets for example(s).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.