How to sort each string in a list of strings with Python

1 Answer

0 votes
lst = ['c', 'python', 'php', 'java', "c#"] 

lst = [''.join(sorted(item)) for item in lst] 

print(lst)



'''
run:

['c', 'hnopty', 'hpp', 'aajv', '#c']

'''

 



answered Jan 21, 2020 by avibootz
...