From 153d71c62d36353833daa025b3a19ef17abf9d05 Mon Sep 17 00:00:00 2001 From: Police Akshith Reddy <100348322+policeakshithreddy@users.noreply.github.com> Date: Wed, 27 Sep 2023 23:42:19 -0700 Subject: [PATCH 1/2] usercustomization.py Added code for user to customize start number when picking from misspellings interactively. --- usercustomization.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 usercustomization.py diff --git a/usercustomization.py b/usercustomization.py new file mode 100644 index 0000000000..9a7522ec48 --- /dev/null +++ b/usercustomization.py @@ -0,0 +1,31 @@ +import re + +def get_misspellings(word): + return {word[i] + word[i+1] + word[i+2] for i in range(len(word)-2)} + +def interactive_misspelling_picker(word, start_number=1): + misspellings = get_misspellings(word) + print(f"Misspellings for '{word}':") + for i, misspelling in enumerate(misspellings, start=start_number): + print(f"{i}. {misspelling}") + + while True: + try: + choice = int(input("Enter the number of the misspelling you want to correct, or 0 to exit: ")) + if choice == 0: + break + elif 1 <= choice <= len(misspellings): + print(f"You chose to correct the misspelling '{list(misspellings)[choice-1]}'.") + break + else: + print("Invalid choice. Please enter a valid number.") + except ValueError: + print("Invalid input. Please enter a number.") + +def main(): + word = input("Enter a word: ") + start_number = int(input("Enter the start number for misspelling selection (default is 1): ") or 1) + interactive_misspelling_picker(word, start_number) + +if __name__ == "__main__": + main() From 2e50c0f27b12454f838eb3d67073826b4f76c636 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 06:46:14 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- usercustomization.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/usercustomization.py b/usercustomization.py index 9a7522ec48..3f09f8bfe5 100644 --- a/usercustomization.py +++ b/usercustomization.py @@ -1,7 +1,6 @@ -import re - def get_misspellings(word): - return {word[i] + word[i+1] + word[i+2] for i in range(len(word)-2)} + return {word[i] + word[i + 1] + word[i + 2] for i in range(len(word) - 2)} + def interactive_misspelling_picker(word, start_number=1): misspellings = get_misspellings(word) @@ -11,21 +10,31 @@ def interactive_misspelling_picker(word, start_number=1): while True: try: - choice = int(input("Enter the number of the misspelling you want to correct, or 0 to exit: ")) + choice = int( + input( + "Enter the number of the misspelling you want to correct, or 0 to exit: " + ) + ) if choice == 0: break elif 1 <= choice <= len(misspellings): - print(f"You chose to correct the misspelling '{list(misspellings)[choice-1]}'.") + print( + f"You chose to correct the misspelling '{list(misspellings)[choice-1]}'." + ) break else: print("Invalid choice. Please enter a valid number.") except ValueError: print("Invalid input. Please enter a number.") + def main(): word = input("Enter a word: ") - start_number = int(input("Enter the start number for misspelling selection (default is 1): ") or 1) + start_number = int( + input("Enter the start number for misspelling selection (default is 1): ") or 1 + ) interactive_misspelling_picker(word, start_number) + if __name__ == "__main__": main()