-----Original Message----- From: tutor-bounces+bermanrl=cfl.rr....@python.org [mailto:tutor-bounces+bermanrl=cfl.rr....@python.org] On Behalf Of Ken G. Sent: Tuesday, February 09, 2010 10:29 AM To: tutor@python.org Subject: [Tutor] rstrip in list?
I printed out some random numbers to a list and use 'print mylist' and they came out like this: ['102\n', '231\n', '463\n', '487\n', '555\n', '961\n'] I was using 'print mylist.rstrip()' to strip off the '\n' but kept getting an error of : AttributeError: 'list' object has no attribute 'rstrip' My memory must be hazy but I thought I had it working several months ago. Any idea or suggestion? TIA, Ken In [14]: mylist Out[14]: ['102\n', '231\n', '463\n', '487\n', '555\n', '961\n'] In [15]: for item in mylist: ....: print item.strip('\n') ....: ....: 102 231 463 487 555 961 I get the impression you can strip something from the elements in the list, but that it balks at a change to the entire list in a single statement? Robert _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor