-
-
Notifications
You must be signed in to change notification settings - Fork 497
Open
Description
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:
- Run the Connect 4 script.
- When prompted "P1's turn. Enter which column you would like to drop your piece into:", enter 8 or higher.
- 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels