Anybody else learning Python right now? I have coded in Perl for 30 years, but I think it’s time to learn Python, so I started taking the “Automate the Boring Stuff with Python” course on Udemy. One of the examples given was a tic-tac-toe game, and since I just watched WarGames yesterday I decided I would write a tic-tac-toe game. I have never written a game in my life, either.
Interestingly I got to the “Put X in the center square” part of WarGames at exactly the same time as my course got to putting X in the center square, and I took a pic of it. I didn’t plan it that way, it just worked out that way.
Anyway, if anyone wants to see and laugh at my code, it’s on GitHub: learning-python/tic-tac-toe.py at master · ataridude/learning-python · GitHub
Considering I’ve never written Python before, I think this is pretty good.
Also, I know of only one issue with the program: I don’t trap a bad move, so if you enter garbage for the move, it crashes. As far as I can tell, it properly detects a win or a stalemate, though, which is cool.
Constructive feedback welcome. Comments of “Convert it to OOP” not welcome.
Edited to add: I have updated it to catch an invalid move.