Skip to content

Using List in Routing #433

Closed Answered by lewysigns
lewysigns asked this question in Q&A
Jul 16, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Thanks.

I wrote this instead, leveraging what I know about the list:

def convert_string_list(string_list):
  try:
    # Remove surrounding brackets and whitespace
    string_list = string_list.strip()[1:-1]

    # Split the string by commas
    elements = string_list.split(',')

    # Remove leading/trailing whitespace from each element
    elements = [element.strip().strip("'") for element in elements]

    # Return the list of strings
    return elements
  except Exception as e:
    print(f"Error: {e}")
    return None

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@stenci
Comment options

@lewysigns
Comment options

Answer selected by lewysigns
@lewysigns
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants