You are viewing a single comment's thread. Return to all comments →
import operator def person_lister(f): def inner(people): people.sort(key=lambda x: (int(x[2]))) return map(f, people) return inner
@person_lister def name_format(person): return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1]
if name == 'main': people = [input().split() for i in range(int(input()))] print(*name_format(people), sep='\n')
Seems like cookies are disabled on this browser, please enable them to open this website
Decorators 2 - Name Directory
You are viewing a single comment's thread. Return to all comments →
import operator def person_lister(f): def inner(people): people.sort(key=lambda x: (int(x[2]))) return map(f, people) return inner
@person_lister def name_format(person): return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1]
if name == 'main': people = [input().split() for i in range(int(input()))] print(*name_format(people), sep='\n')