Populating a list
A. Keyton Weissinger
keyton at weissinger.org
Mon Dec 10 02:01:48 CET 2001
So we're clear. You can either do it this way:
states = 
for i in f:
The rstrip() method, as you can probably guess, strips white spaces from the
RIGHT end of the string.
or (from Mr. Martelli -- I like this one better):
f = open('/home/mlorfeld/states.txt', 'r+')
states = [ line[:-1] for line in f.readlines() ]
Sorry for the misinformation, folks.
More information about the Python-list