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
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to