[Tutor] A simple list question...
Richard Querin
rfquerin at gmail.com
Fri Sep 8 04:49:53 CEST 2006
I've got a list of strings. There are some duplicates. I want a list
of only the unique entries in that list. So I do the following:
mylist = ['project1' , 'project2', 'project3', 'project4', 'project1']
d = {}
for item in mylist:
d[item] = None
cleanedlist = d.keys()
But d.keys() seems to add '\n' to each entry in cleanedlist.
1. How can I easily strip out the newline characters from the elements
of cleanedlist?
2. Is there a better way to achieve my objective (ie. a list method
for generating the cleaned list?)
More information about the Tutor
mailing list