Python 3 sort() problem

Владислав vladislav86 at inbox.ru
Mon Aug 17 13:42:11 CEST 2015


# 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?



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150817/1a2d4720/attachment.html>


More information about the Python-list mailing list