daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. name=input("Enter your name:")
  2. #string to list conversion
  3. list_char=list(name)
  4. print("\n")
  5. print(list_char)
  6.  
  7. #simple sort for list items
  8. for i in range(len(list_char)):
  9.   for j in range(i+1,len(list_char)):
  10.     if (list_char[i]>list_char[j]):
  11.      temp=list_char[i]
  12.      list_char[i]=list_char[j]
  13.      list_char[j]=temp
  14.  
  15. #list to string conversion
  16. new_string=""
  17.  
  18. for i in range(len(list_char)):
  19.  new_string+=list_char[i]
  20.  
  21. #string with sorted characters
  22. print("Sorted String: "+new_string)
  23.  
  24.  
  25. '''
  26. Output
  27.  
  28. Python 3.6.1 (default, Dec 2015, 13:05:11)
  29. [GCC 4.8.2] on linux
  30.    
  31. Enter your name: axouprbnfgr
  32.  
  33. ['a', 'x', 'o', 'u', 'p', 'r', 'b', 'n', 'f', 'g', 'r']
  34.  
  35. Sorted String: abfgnoprrux
  36.  
  37.  
  38.  
  39.  
  40. '''
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top