codescracker


python

Python Program to Sort String in Alphabetical Order



« Previous Program Next Program »


Sort String in Alphabetical Order in Python

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.

Python Programming Code to Sort String in Alphabetical Order

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:

python sort string in alphabetical order

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test