#给输入的用户按照首字母排序##!/usr/bin/env python#coding:utf-8'''Program:    Sort and output by nameHistory:2017.03.29      Mr.liu      First release''''''total = input("the total number of name:")li = []errcount = 0count = 0while count < total:    name = raw_input("Please input %d name(s): \n" % (4 - count))    if "," in name:        li.append(name)        count += 1    else:        errcount += 1        print "ERROR:%d time(s) bad input:',' \n Please try agin." %(errcount)li = sorted(li)dic = {}.fromkeys(li)print "The sorted list by first name is:"for d in dic.keys():    print d'''count = input("Enter total munber of name:")li = []errCount = 0i = 0while i < count:    name = raw_input("Please input your name:")    if "," in name and "," != name[0] and name.index(",") != len(name) - 1 and name.count(",") == 1:        li.append(name)        i += 1    else:        errCount += 1        print "ERROR:%d time(s) bad input:',' Please try agin." %(errCount)else:    li = sorted(li)print "The sorted list by first name is:"for i in li:    print i