从包含联系人信息的一组给定记录中,找到重复的记录,如果存在不同的联系人,则将其合并,否则拒绝使用重复的记录。记录的格式为:
record id first_name second_name contact
例如:
001 Ram Sharma ram@gmail.com
002 Jai Kishor 9997125640
003 Ram Sharma ram@gmail.com
004 Krishna Gupta ksh@yahoo.com
005 Ram Sharma ram@gmail.com
006 Jai Kishor 1276594888
007 Ram Sharma ram-new@gmail.com
输出:
001 Ram Sharma ram@gmail.com, ram-new@gmail.com 002 Jai Kishor 9997125640, 1276594888 004 Krishna Gupta ksh@yahoo.com
您可以使用dictionary并使用key(带有记录id)、value(带有第一个\u名称、第二个\u名称和联系人列表的元组)分配它:
作为键、值打印的dict输出
假设输入为原始文本,则可以使用集合来组合任何精确的副本
代码:
输出
相关问题 更多 >
编程相关推荐