CSUIDL PROGRAMMEr wrote:
folks,
I am new to python.
I have a list made of elements
['amjad\n', 'kiki\n', 'jijiji\n']
I am trying to get rid of '\n' after each name.
to get list as
['amjad','kiki','jijiji']
But list does not have a strip function as string does have.
What would a list.strip() method mean on a list of integers ?
is there any solutions
mylist = ['amjad\n', 'kiki\n', 'jijiji\n']
print "with map : "
print map(str.lstrip, mylist)
print "with list comprehension :"
print [line.lstrip() for line in mylist]
print "with a for loop :"
strippedlist = []
for line in mylist:
strippedlist.append(line.lstrip())
print strippedlist
Is there a way this can be done??
Probably. Reading some CS101 tutorial might be a good idea...
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"