ah there's no return question then
that precisely returned the discussion to the first answer
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
On Thu, 17 May 2018, 23:35 Tobiah, wrote:
> On 05/17/2018 09:25 AM, Ned Batchelder wrote:
> > On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer w
>new_list = list(x.remove(0))
>new_list = x.remove(0)[:]
Please disregard :)
kh
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, May 17, 2018 at 3:27 PM, Karsten Hilbert
wrote:
>> On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote:
>> > x = [0,1]
>> > x.remove(0)
>> > new_list = x
>> >
>> > instead i want in one go
>> >
>> > x = [0,1]
>> > new_list = x.remove(0) # here a way for it to return the modified list by
>>
> On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote:
> > x = [0,1]
> > x.remove(0)
> > new_list = x
> >
> > instead i want in one go
> >
> > x = [0,1]
> > new_list = x.remove(0) # here a way for it to return the modified list by
> > adding a .return() maybe ?
>
> There isn't a way to do that in
On 05/17/2018 09:25 AM, Ned Batchelder wrote:
On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote:
x = [0,1]
x.remove(0)
new_list = x
Just call the original list 'new_list' to begin with.
new_list = [0, 1]
new_list.remove(0)
There you are!
--
https://mail.python.org/mailman/listinfo/pyt
On 17-May-2018 12:37, Ned Batchelder wrote:
> On 5/17/18 12:28 PM, Dan Strohl via Python-list wrote:
> > On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> > > I don't understand what this would return? x? You already have x. Is
> > > it meant to make a copy? x has been mutated, so I don't
On 5/17/18 12:28 PM, Dan Strohl via Python-list wrote:
On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
I don't understand what this would return? x? You already have x. Is
it meant to make a copy? x has been mutated, so I don't understand the
benefit of making a copy of the 1-less x. C
On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> I don't understand what this would return? x? You already have x. Is
> it meant to make a copy? x has been mutated, so I don't understand the
> benefit of making a copy of the 1-less x. Can you elaborate on the
> problem you are trying
On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote:
x = [0,1]
x.remove(0)
new_list = x
instead i want in one go
x = [0,1]
new_list = x.remove(0) # here a way for it to return the modified list by
adding a .return() maybe ?
There isn't a way to do that in one line. I often find myself splitt
x = [0,1]
x.remove(0)
new_list = x
instead i want in one go
x = [0,1]
new_list = x.remove(0) # here a way for it to return the modified list by
adding a .return() maybe ?
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
On Thu, 17 May 2018, 19:54 Alexandre Brault, wrote:
>
> On 2018
On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> I don't understand what this would return? x? You already have x. Is it
> meant to make a copy? x has been mutated, so I don't understand the benefit
> of making a copy of the 1-less x. Can you elaborate on the problem you are
> trying to
On Thu, 17 May 2018, 18:55 Ned Batchelder, wrote:
> On 5/17/18 4:23 AM, Abdur-Rahmaan Janhangeer wrote:
>
> if then a more convenient way might be found to naturally remove and
> return the list
>
> maybe it was not included as one might want to remove the list only
>
> x = [1]
> x.remove(1)
>
>
On 5/17/18 4:23 AM, Abdur-Rahmaan Janhangeer wrote:
if then a more convenient way might be found to naturally remove and
return the list
maybe it was not included as one might want to remove the list only
x = [1]
x.remove(1)
as opposed to
x = [1]
x.remove(1)
new_list = x
i was looking for l
Abdur-Rahmaan Janhangeer at 2018/5/17 PM 04:23 wrote:
if then a more convenient way might be found to naturally remove and return
the list
maybe it was not included as one might want to remove the list only
x = [1]
x.remove(1)
as opposed to
x = [1]
x.remove(1)
new_list = x
IMO, this way is
if then a more convenient way might be found to naturally remove and return
the list
maybe it was not included as one might want to remove the list only
x = [1]
x.remove(1)
as opposed to
x = [1]
x.remove(1)
new_list = x
i was looking for like
x = [1]
x.remove(1).return()
ps. list is was demo
On Wednesday, May 16, 2018 at 7:42:01 PM UTC-7, Abdur-Rahmaan Janhangeer wrote:
> why is x = list.remove(elem) not return the list?
>
> Abdur-Rahmaan Janhangeer
> https://github.com/Abdur-rahmaanJ
1) If you are naming your list "list," you're asking for trouble. Shadowing
builtin names is risky
On 5/16/18 10:41 PM, Abdur-Rahmaan Janhangeer wrote:
why is x = list.remove(elem) not return the list?
Methods in Python usually do one of two things: 1) mutate the object and
return None; or 2) leave the object alone and return a new object. This
helps make it clear which methods mutate and
why is x = list.remove(elem) not return the list?
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
--
https://mail.python.org/mailman/listinfo/python-list
18 matches
Mail list logo