Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions list.py
Original file line number Diff line number Diff line change
@@ -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}")