why i have the output of [None, None, None]

Rustom Mody rustompmody at gmail.com
Thu Apr 10 10:18:33 EDT 2014


This is called imperative programming:

for it in x:
...   if it.strip() != '':
...        print ("Ok")

This is called functional programming:
>>> [y for y in x if y.strip() != '']
['x1', 'x2', 'x3']

What you have is a confusion:
print is imperative
comprehension is functional
You should not mix them like that



More information about the Python-list mailing list