Given a list, how I generate the list separated by a give value
# Problem
items = ["a", "b", "c"]
expected_result = ["a", "separator", "b", "separator", "c"]
# solution should look like
items = [ item, "separator" for item in items]
Given a list, how I generate the list separated by a give value
# Problem
items = ["a", "b", "c"]
expected_result = ["a", "separator", "b", "separator", "c"]
# solution should look like
items = [ item, "separator" for item in items]
items = ["a", "b", "c"]
separated_list = []
for element in items:
separated_list += [element]
separated_list += ["separator"]
separated_list = separated_list[:-1]