To sort string in alphabetical order, you have to ask from user to enter any string to sort the entered string in alphabetical order and print the sorted string as output as shown in the program given below.
Following python program ask from the user to enter the string to sort it into alphabetical order to display the sorted string:
# Python Program - Sort String in Alphabetical Order while True: print("Enter 'x' for exit.") string = input("Enter any string: ") if string == 'x': break else: ''.join(sorted(string)) print()
Here is the sample run of the above python program to show how to sort string in alphabetical order:
You may also like to learn or practice the same program in other popular programming languages: