How to convert a string consisting of words separated by spaces, and sort the resulting list in a lexicographic order?
is given a line from words separated by spaces:
S = 'ABC a BCD BC ABC BC BCD BCD ABC'PREA>We convert it to the "Space" "" Space "":
A = S.Split ( '' ) we get:
[ 'Abc' , '' a ', ' bcd ', ' bc ', 'Abc' , 'bc' , 'bcd' , '' bcd ', 'ABC' ] class = ""> print (a) pre>
we will not get anything if:
b = a.sort () Print (a) We get the sorted list
[ 'ABC' , 'Abc' , 'bc' , '' "> '' bcd ', '` `` span>, 'ABC' , 'bc' , 'bcd' , '' "> ''"> '' "]why? Is it possible to somehow combine sort () and split () in one line?
question@mail.ru
·