Dec-14-2017, 01:43 PM
(Dec-13-2017, 09:51 PM)j.crater Wrote: What in particular is the trouble you are having? Post the code of your attempt of tackling the problem in Python code tags, and potential error messages in error code tags, and we will look into it.
Hi there, here's my current code:
f = open("Categories List.txt", "r") cList = f.read() f.close() cList = cList.split("\n") array = {} lastR = "" for r in cList: if r[0] == "\t": array[lastR].append(r[1:]) else: lastR = r array[lastR] = [] print(array)As you can see, it works fine with only one level of indentation, however, once there are multiple tabs prefixing a line, it will not correctly insert that into the correct array position. I am just not sure how to store the data in such a way you can dynamically add to any depth of the array.