+ 2

How can I make an input string into a list to sort it alphabetically

Example - string :- sort in alphabetical order Output- alphabetical in order sort

7th Aug 2020, 12:54 PM
Amit Kumar
Amit Kumar - avatar
9 odpowiedzi
+ 4
list(input()) will split the input into a list of alphabets. Then sort() will sort it for you.
7th Aug 2020, 2:17 PM
Bongumusa
Bongumusa - avatar
+ 4
i think that a more clear sample for input and output would be helpful. Input = 'sololearn' output = 'aellnoors' if this is what you want to get, you can do this: (1) use list(input) to create a list with all individual characters of the input string (2) sort this list (3) ''.join() the list to a string (4) printbthe string
7th Aug 2020, 2:41 PM
Lothar
Lothar - avatar
+ 3
input().split()
7th Aug 2020, 12:55 PM
Abhay
Abhay - avatar
7th Aug 2020, 4:18 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Yup that split() methods converts a string into list based on argument provided to it ,
7th Aug 2020, 12:56 PM
Abhay
Abhay - avatar
+ 1
I know how to sort list but don't know how to make input string into list
7th Aug 2020, 12:55 PM
Amit Kumar
Amit Kumar - avatar
+ 1
Ok I will try
7th Aug 2020, 12:57 PM
Amit Kumar
Amit Kumar - avatar
+ 1
Actually I wanted to sort a list but still keep it as a list (a,b,c)😅 but still thank you it might help me in the future
7th Aug 2020, 2:44 PM
Amit Kumar
Amit Kumar - avatar
+ 1
Ashkey has already solved it.. But I just want to help https://code.sololearn.com/cGEuDh8vMkDz/?ref=app
8th Aug 2020, 10:50 PM
Boniface Delali Dakey
Boniface Delali Dakey - avatar