diff --git a/src/download/download.py b/src/download/download.py index f49b501..d01e3b8 100644 --- a/src/download/download.py +++ b/src/download/download.py @@ -128,7 +128,16 @@ def print_webcomics(webcomics: Dict[str, Dict]) -> int: for index, entry in enumerate(webcomics["webcomics"]): print(list_lines(index, entry["name"])) - return int(input("Select a webcomic: ")) + max_index = len(webcomics["webcomics"]) - 1 + while True: + raw = input("Select a webcomic: ").strip() + if not raw.isdigit(): + print("Please enter a number.") + continue + choice = int(raw) + if 0 <= choice <= max_index: + return choice + print(f"Please enter a number between 0 and {max_index}.") def webcomic_manager():