Clear output and rewrite it in python
Question: Hi I'm trying to make a tic tac toe game in python and I've run into a
problem. ![enter image description here](http://i.stack.imgur.com/hvIIA.png)

As you can see on the picture it rewrites the playing board after your input,
what I want it to do is to clear the output and then rewrite the board. So
instead of just printing new boards all the time it only clears the current
board and rewrites it. I've searched on "clear output" etc, but all I find is
these kind of codes:

    
    
    import os
    clear = lambda : os.system('cls')
    

or

    
    
    import os
    def clear():
    os.system( 'cls' )
    

Using this clear function above don't work for me. It only returns this
symbol:[![enter image description
here](http://i.stack.imgur.com/2iFLF.png)](http://i.stack.imgur.com/2iFLF.png)

I am currently writing my code in Pycharm and just to make it clear, I wanna
keep it in pycharm.


Answer: I see a syntax error from your code, you are missing the ":".

    
    
    clear = lambda : os.system('cls')
    

However avoid lambda and define a function for clear because it is easier to
read.

    
    
    def clear():
        os.system( 'cls' )
    

then you can clear the window with:

    
    
    clear()
    

