There was so many different solutions presented here to me.
Thanks to all. By adding '.strip('\n') to the last two lines below, it
came out:
Sorted List
['102', '231', '463', '487', '555', '961']
for line in file.readlines():
print line.strip('\n'),
mylist.append(line.strip('\n'))
Fu
On Tue, Feb 9, 2010 at 11:09 AM, Ken G. wrote:
>
> Kent Johnson wrote:
>
> On Tue, Feb 9, 2010 at 10:28 AM, Ken G. wrote:
>
>
> I printed out some random numbers to a datafile and use 'print mylist' and
> they came out like this:
>
> ['102\n', '231\n', '463\n', '487\n', '555\n', '961\n']
>
>
> Ho
-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
Ken G. wrote:
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 at
Kent Johnson wrote:
On Tue, Feb 9, 2010 at 10:28 AM, Ken G. wrote:
I printed out some random numbers to a datafile and use 'print mylist' and
they came out like this:
['102\n', '231\n', '463\n', '487\n', '555\n', '961\n']
How are you generating this list? You should be able to creat
On Tuesday 09 February 2010 16:28:43 Ken G. wrote:
> ['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'
A string has attribute rstrip
On Wed, 10 Feb 2010 02:28:43 am Ken G. wrote:
> 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
On Tue, Feb 9, 2010 at 10:28 AM, Ken G. wrote:
> 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']
How are you generating this list? You should be able to create it
without the \n. That woul
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