Well, how about collecting all the individual lists into a single list and then joining the individual items together.
Approach 1:- Collecting all the list and then joining them
intermidiate_list = list()
for i in range(len(mega_list)):
intermidiate_list.extend(mega_list(i))
result = ";".join(intermidiate_list)
Here mega_list
is the collection of all the lists you have. You can iterate over them by indexes and still make it work.
Approach 2:- Generating the list on the fly
result = str()
small_list = get_list()
while small_list:
result += ";".join(small_list)
small_list = get_list()
if small_list and len(small_list) > 0:
result += ";"
Now iterate the logic for all the list items you generate, in the end result will have the