View Single Post
Old 10-22-2014, 10:36 AM   #2
cliffbeall
Senior Member
 
Location: Ohio

Join Date: Jan 2010
Posts: 144
Default

It doesn't know what to do with the print inside the list comprehension.

If you really want it in one line, how about:

To print the first one:
Code:
print [i+" doesn't end with .pdb" for i in file_name if not i.endswith(".pdb")][0]
To print all:
Code:
print '\n'.join([i+" doesn't end with .pdb" for i in file_name if not i.endswith(".pdb")])

Last edited by cliffbeall; 10-22-2014 at 10:52 AM. Reason: To put in 2nd case
cliffbeall is offline   Reply With Quote