Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Mark Lawrence
On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. Lists are mutabl

Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Mike C
Mark Lawrence Sent: Monday, September 3, 2018 2:21:36 PM To: python-list@python.org Subject: Re: Why list.reverse() modifies the list, but name.replace() does not modify the string? On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a m

Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Chris Angelico
On Tue, Sep 4, 2018 at 3:49 AM, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. > >

Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Joel Goldstick
On Mon, Sep 3, 2018 at 1:50 PM C W wrote: > > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: > > L = [3, 6, 1,4] > > L.reverse() > > L > [4, 1, 6, 3] > This changes the original list.

Re: Why list.reverse() modifies the list, but name.replace() does not modify the string?

2018-09-03 Thread Mike C
f of Mark Lawrence Sent: Monday, September 3, 2018 2:21:36 PM To: python-list@python.org Subject: Re: Why list.reverse() modifies the list, but name.replace() does not modify the string? On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know

Re: Why list.reverse() modifies the list, but name.replace() does not modify the string?

2018-09-03 Thread Mark Lawrence
On 03/09/18 18:49, C W wrote: Hello all, I am learning the basics of Python. How do I know when a method modifies the original object, when it does not. I have to exmaples: Example 1: L = [3, 6, 1,4] L.reverse() L [4, 1, 6, 3] This changes the original list. Lists are mutable, i.e. can be ch

Re: Why list.reverse() modifies the list, but name.replace() does not modify the string?

2018-09-03 Thread Chris Angelico
On Tue, Sep 4, 2018 at 3:49 AM, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. > >

Re: Why list.reverse() modifies the list, but name.replace() does not modify the string?

2018-09-03 Thread Joel Goldstick
On Mon, Sep 3, 2018 at 1:50 PM C W wrote: > > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: > > L = [3, 6, 1,4] > > L.reverse() > > L > [4, 1, 6, 3] > This changes the original list.