def translate(): spanish = {"one":"uno","cat":"gato","I":"yo"} sentence = raw_input("Enter a sentence: ") #print sentence sentenceList = sentence.split() #print sentenceList spanishList = [] for word in sentenceList: spanishWord = spanish.get(word, word) spanishList.append(spanishWord) # spanishList += [spanishWord] #print spanishList spanishSentence = " ".join(spanishList) return spanishSentence def printSorted(dict): #print dict keys = dict.keys() #print keys keys.sort(key=str.lower) # trick to fold in uppercase #print keys for key in keys: print key, dict[key] # the following will appear in normal alphabetic order now printSorted({"one":"uno","cat":"gato","I":"yo"})