Re: Python 3 sort() problem

2015-08-17 Thread Rustom Mody
On Monday, August 17, 2015 at 7:32:08 PM UTC+5:30, Владислав wrote: > # first: works fine > x = [1, 2, 4, 2, 1, 3] > x = list(set(x)) > x.sort() > print(x)  # output: 1, 2, 3, 4 > > # second: why x became None ?? > x = [1, 2, 4, 2, 1, 3] > x = list(set(x)).sort() > print(x)  # output: None > I kno

Re: Python 3 sort() problem

2015-08-17 Thread Mark Lawrence
On 17/08/2015 12:42, Владислав wrote: # first: works fine x = [1, 2, 4, 2, 1, 3] x = list(set(x)) x.sort() print(x) /# output: 1, 2, 3, 4 /# second: why x became None ?? x = [1, 2, 4, 2, 1, 3] x = list(set(x)).sort() print(x) /# output: None/ I know that sort() returns None, but I guess that

Re: Python 3 sort() problem

2015-08-17 Thread Fabien
On 08/17/2015 01:42 PM, Владислав wrote: x = [1, 2, 4, 2, 1, 3] x = list(set(x)).sort() print(x) /# output: None/ I know that sort() returns None, but I guess that it would be returned x that was sorted. Why so? If sort() returns None, than the following: x = list(set(x)).sort() is equivalen

Re: Python 3 sort() problem

2015-08-17 Thread Joonas Liik
> > I know that sort() returns None, but I guess that it would be returned x > that was sorted. Why so? if it returned a sorted list it might lead some people to believe it did not modify the oridinal list which would lead to a ton of confusion for new users. -- https://mail.python.org/mailman/li

Python 3 sort() problem

2015-08-17 Thread Владислав
# first: works fine x = [1, 2, 4, 2, 1, 3] x = list(set(x)) x.sort() print(x) # output: 1, 2, 3, 4 # second: why x became None ?? x = [1, 2, 4, 2, 1, 3] x = list(set(x)).sort() print(x) # output: None I know that sort() returns None, but I guess that it would be returned x that was sorted. Wh