Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sort_str(string_1):
- count=0
- s=string_1[0]
- new_str=""
- if len(string_1) != 1:
- while count==0:
- for i in range(len(string_1)):
- if ord(string_1[i])<ord(s):
- s = string_1[i]
- index_char = i
- str1 = sort_str(string_1[0:index_char])
- str2 = string_1[index_char+1:]
- new_str = str1+str2
- count+=1
- return new_str+s
- else:
- return string_1
- print("Please enter a string to sort: ")
- s = input()
- print(f"The string to sort is:{s}")
- print(f"The sorted string is:{sort_str(s)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement