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 know that sort() returns None, but I guess that it would be returned x that 
> was sorted. Why so?
> 
> 
>  

Maybe you want sorted?
>>> x = [4,2,1,3]
>>> sorted(x)
[1, 2, 3, 4]

[The list(set(..)) is probably for removing duplicates. Right?
Which you seem to have worked out it seems?
So best when asking questions to focus on one issue at a time]
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to