On Thu, May 17, 2018 at 3:27 PM, Karsten Hilbert <karsten.hilb...@gmx.net> 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 >> > adding a .return() maybe ? >> >> There isn't a way to do that in one line. > > new_list = list(x.remove(0)) > new_list = x.remove(0)[:] > > ? > > No one said x can't be modified, only that new_list is > to contain the modified list after one line of code :)
Did you actually run either of those? -- https://mail.python.org/mailman/listinfo/python-list