DEV Community

TBSveryfunny
TBSveryfunny

Posted on

Connect 4 Terminal Game in Python

Connect 4 is a classic game played for generations. As part of the Codecademy Computer Science career path, I have decided to create a simple implementation of it in the Python Terminal.

Image description

The program first creates a blank board as a two-dimensional list, using list comprehensions. It then asks for the names of both players. Once both players are named, the program asks each player to drop their token into one of the seven columns. While loops are utilized to validate input, and to prevent a user from dropping a token into a column that is full. To check for the winner of the game, for loops and if-else statements are used to check for every possible win condition. This is clearly un-ideal, but I believe this is simply another avenue for improvement.

The program functions well as is, although another improvement would be to create a system to validate for integers.

The code is linked here.

Top comments (0)