in CODING, Python

List Comprehension

Learnt this from someone today. Instead of writing a full for... loop

goodlist = []
for x in mylist:
  if x['package'] != None:
    goodlist.append(x)

It can be shortened to…

goodlist = []
goodlist = [x for x in mylist if x['package'] != None]