# Python program to sort a string in alphabetical order
string = input("Enter the string : ")
j = 0
str1 = ""
temp = 0
str = list(string)
for i in range(0, len(str)):
for j in range(0, len(str)):
if(str[j] > str[i]):
temp = str[i]
str[i] = str[j]
str[j] = temp
print("The sorted string is : ")
print(str1.join(str))
Output :
Enter the string : edcba
The sorted string is :
abcde



0 comments:
Post a Comment
gurnoorsingh5974@gmail.com