Sort by

recency

|

228 Discussions

|

  • + 0 comments
    import operator
    def person_lister(f):
        def inner(people):
            for x in people:
                x[2] = int(x[2])
            people.sort(key=operator.itemgetter(2))
            return [f(x) for x in 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')
    
  • + 0 comments
    def person_lister(f):
        def inner(people):
            return [f(p) for p in sorted(people,key = lambda x: int(x[-2]))] 
        return inner
    
  • + 0 comments
    import operator
    
    def person_lister(f):
        def inner(people):
            sorted_people = sorted(people, key=lambda x: int(x[2]))
            format_people = [f(person) for person in sorted_people]
            return format_people
        return inner``
    
  • + 0 comments
    def person_lister(f):
        def inner(people):
            # complete the function
            sp = sorted(people, key=lambda x: int(x[2]))
            def title(r):
                return "Mr." if r[3]=="M" else "Ms."
            return map(lambda r: f"{title(r)} {r[0]} {r[1]}", sp)
        return inner
    
  • + 0 comments

    This is definitely 1 of the hard ones after trying 94 examples.. not easy at all.