[Nick] > Why is there a apostrophe still at the end? [Stephen] > Is it possible that you actually have whitespace at the end > of the line?
It's the newline - reading lines from a file doesn't remove the newlines: from cStringIO import StringIO DATA = """\ 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania' 'DZ':'DZA':'012':'ALGERIA':'Algeria' 'AS':'ASM':'016':'AMERICAN SAMOA':'American Samoa' """ f1 = StringIO(DATA) for line in f1: print repr(line.rsplit(':')[4].strip("'")) # repr shows the error # This prints: # # "Afghanistan'\n" # "Albania'\n" # "Algeria'\n" # "American Samoa'\n" # # Do this instead: f1.seek(0) for line in f1: print line.strip().rsplit(':')[4].strip("'") # This prints: # # Afghanistan # Albania # Algeria # American Samoa -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list