This is a way of appending to a list through for loop:
lst = []
for i in range(5):
lst.append(i)
Though the below may look nicer and better:
lst = [i for i in range(5)]
I was trying to write the below code same as the second format, but I keep getting error. can anyone help?
filtered_list = []
for childList in source_list:
filtered_childList = remove_emptyElements(childList)
if filtered_childList:
filtered_list.append(filtered_childList)