Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 31, 2021 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/2905e4a13842131520882134a3a04692 to your computer and use it in GitHub Desktop.
Save amankharwal/2905e4a13842131520882134a3a04692 to your computer and use it in GitHub Desktop.
# create empty list
empty_lst = []
# multiple nested loops to store all post in empty list
for dct in data:
for k, v in dct.items():
if k == 'data':
if len(v) > 0:
for k_i, v_i in v[0].items():
if k_i == 'post':
empty_lst.append(v_i)
print("This is the empty list: ", empty_lst)
print("\nLength of list: ", len(empty_lst))
for i in empty_lst:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment