From 93e3985cff633f3fb53bf8cca9c64d902e655cd1 Mon Sep 17 00:00:00 2001 From: Divesh Chauhan <165630306+divesh2022@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:30:53 +0530 Subject: [PATCH] Create list.py --- list.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 list.py diff --git a/list.py b/list.py new file mode 100644 index 0000000..4ffb22c --- /dev/null +++ b/list.py @@ -0,0 +1,20 @@ +# creating a list from single line input +try: + # enter the separator + separator = input("Enter the separator symbol (e.g., ',' or '-') : ") + if not separator: + raise ValueError("Separator cannot be empty.") + + # enter the string + string = input("Enter the string: ") + if not string: + raise ValueError("Input string cannot be empty.") + + # split the string using the separator + lst = string.split(separator) + print("List:", lst) + +except ValueError as e: + print(f"Error: {e}") +except Exception as e: + print(f"An unexpected error occurred: {e}")