I'm attempting to make a pipe delimited list or an array in python 3 from strings I'm pulling out of a JSON file within a for loop, but how do I do this?
Say I have some code that grabs strings "string0", "string1", "string2", "string3", ... , "stringN" from a json file using a for loop.
I want the output to look something like
["string0" | "string1" | "string2" | "string3" | ... | "stringN"]
once I'm done.
UPDATED PHRASING: I have N distinct strings as input. I want these strings in an object that's pipe separated and can be mutable and iteratable.
I was expecting there to be something like:
with open("some.json") as f:
db = json.load(f)
strings = []
for i in len(db["stringLocation"]):
string = db["stringLocation"][i]["str"]
strings.append(string, sep = "|")
...or something like that.
Is there a way to do this?
Thanks in advance, and sorry if this has already been asked in some other form. I feel like perhaps I just don't have the right functions or data objects in mind to search this at the moment.