Connect Four: IndexError due to absence of input validation

Describe the bug
The game crashes with an IndexError when a player inputs a column number that is greater than the board's width (e.g., Column 8, 9, or 10 on a 0-indexed 7-column board). The input is not being sanitized or compared against the maximum column index before the board array is accessed.

To Reproduce
Steps to reproduce the behavior:

  1. Run the Connect 4 script.
  2. When prompted "P1's turn. Enter which column you would like to drop your piece into:", enter 8 or higher.
  3. See error: IndexError: list index out of range.

Expected behavior
The application should validate the input. If the input is < 0 or > 7, it should display an error message like "Invalid Column! Please choose a number between "0 and 6" and prompt the user for a new input.

Desktop (please complete the following information):

  • macOS
  • Terminal
  • Python3