"""File: sort_string1.py Purpose: Sort the characters in a string into increasing order Run: python sort_string1.py Input: A string consisting of lower-case letters Output: The strings characters sorted in increasing order """ def how_many(let, s): """Count the number of times let occurs in s""" count = 0 for l in s: if l == let: count = count+1 return count #---------------------------------------------------------------------- def sort_string(s): """Sort the characters in s into increasing order""" t = "" for let in "abcdefghijklmnopqrstuvwxyz": count = how_many(let,s) if count > 0: t = t + count*let return t #---------------------------------------------------------------------- word = raw_input("Enter a word\n ") sorted = sort_string(word) print "After sorting the letters in", word, "we have", sorted