Converted names.py to a list comprehension
This commit is contained in:
parent
0e706b83b2
commit
36c0cffa3a
|
@ -1,12 +1,9 @@
|
|||
def main():
|
||||
with open('names.txt', 'r') as f:
|
||||
names = f.read().split('\n')
|
||||
surnames = set([name.split(' ')[-1] for name in names[1:]])
|
||||
namesDict = {}
|
||||
for surname in surnames:
|
||||
namesDict[surname] = set([name.split(' ')[0] for name in names[1:] if surname in name and surname != ''])
|
||||
namesDict = {surname: set([name.split(' ')[0] for name in names[1:] if surname in name])
|
||||
for surname in set([name.split(' ')[-1] for name in names[1:] if name != ''])}
|
||||
|
||||
del namesDict['']
|
||||
printNames(namesDict)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue