How to sort a string in python?

A collection of one or more characters put in single, double or triple quotes is known as string in python.
Here we’ll see how to sort a string.
We use sorted() function to sort the string.
e.g.,
a="Python Point" print(sorted(a))

We can use join() and sorted() function both to sort the string.
e.g.,
a="Hello world" print(" ".join(sorted(a)))

This is how we can sort a string in python.
Subscribe
Login
Please login to comment
0 Discussion