0

i am getting list using below code. i am new to python and cant figure out how to combine 18 list into one. I am getting data from api so it only shows 50 results at one time.

list_2 = ([sub['Function'] for sub in resources])
print(list_2)

Print Results

[a,b,c.....ds] --50 items in list
[bc,kj,sd,...mp] --50 items in list
[fj,lk,ld,...dh] --50 items in list and so on i get upto 18 list when i print list 2

how can i combine list_2.

so i can get all one list with 900 items rather than 18 list of 50 items each

Olvin Roght
  • 7,677
  • 2
  • 16
  • 35

1 Answers1

1

If you are trying to flatten your List of Lists, you can use two nested for loops and append all iterated items to a new list:

flatted_list = []
for sublist in list_2:
    for item in sublist:
        flat_list.append(item)
dmuensterer
  • 1,875
  • 11
  • 26
  • This gives me multiple list again by breaking each by single alphabet separated by comma so output for word "mkfj" will look like ['m','k','f','j'] – user1742716 Jun 14 '20 at 23:47