+ 2

python : single liner

'''why this code returns none''' list = input().split(',').sort() '''but this not give None''' list = input().split(",") list.sort()

20th Nov 2022, 4:10 AM
Sunil Shrestha
Sunil Shrestha - avatar
5 ответов
+ 2
The `None` came from (returmed by) sort(), as it sorts the `list` in place instead of returning a sorted copy of the `list` like the sorted() function.
20th Nov 2022, 4:20 AM
Ipang
+ 2
Sunil Shrestha use sorted() as suggested by Ipang list = sorted(input().split(','))
21st Nov 2022, 11:22 AM
Bob_Li
Bob_Li - avatar
+ 1
doesnt split function return any value?
20th Nov 2022, 4:11 AM
Sunil Shrestha
Sunil Shrestha - avatar
+ 1
means sort doesnt return value
20th Nov 2022, 5:42 AM
Sunil Shrestha
Sunil Shrestha - avatar
0
Yes that's right
20th Nov 2022, 5:53 AM
Ipang