Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Input Validation and Error Handling:
Implemented the get_valid_integer function to ensure that the key entered by the user is a valid integer.
Added prompts for the user to input a custom alphabet or use the default one.
Refactoring Code Structure:
Encapsulated the main menu logic within a main function.
Separated concerns by creating helper functions for input validation.
PEP 8 Compliance:
Adjusted code formatting, such as adding spaces around operators and after commas.
Ensured that line lengths do not exceed 79 characters where possible.
Enhanced Docstrings:
Updated docstrings to provide clearer and more concise explanations.
Used consistent formatting for parameters and return values.
Type Hinting:
Used Optional[str] from the typing module for better type hinting.
Specified return types for all functions.
Modularization:
Separated user interaction from the core logic, making the code more modular and easier to test.
This separation allows the core functions to be reused in other modules or scripts.
User Experience Improvements:
Enhanced the main menu to display options in a more readable format.
Allowed users to specify a custom alphabet, providing more flexibility.
Added clear prompts to guide the user through the steps.
Edge Case Handling:
Improved handling of large key values by using modulo operation to wrap around the alphabet.
Ensured that the cipher works correctly even when the key is larger than the length of the alphabet.