I\'m having issues in reading a file into a list, When I do it only creates one item from the entire file rather than reading each element into its own field. I\'m using
This incorporates the strip directly into the for statement.
with open('drugs', 'r') as f:
for line in map(lambda line: line.rstrip('\n'), f):
print line
Or, if you know you don't need any space before or after text on a line, you can use this.
import string
with open('drugs', 'r') as f:
for line in map(string.strip, f):
print line