-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroup by owners
50 lines (34 loc) · 1.22 KB
/
Group by owners
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Created on Mon Oct 8 19:21:54 2018
@author: sumit
Implement a group_by_owners function that:
Accepts a dictionary containing the file owner name for each file name.
Returns a dictionary containing a list of file names for each owner name, in any order.
For example, for dictionary {'Input.txt': 'Sandy', 'Code.py': 'Stan', 'Output.txt': 'Sandy'} the group_by_owners function should return {'Randy': ['Input.txt', 'Output.txt'], 'Stan': ['Code.py']}.
"""
class FileOwners:
files = {
'Input.txt': 'Sandy',
'Code.py': 'Stan',
'Output.txt': 'Sandy'
}
@staticmethod
def group_by_owners(files):
temp=[]
for i in files:
print(i)
print ('%$%$', (files[i]))
if files[i] not in temp:
temp.append (files[i])
result={}
for j in temp:
temp1=[]
for i in files:
print(files[i])
print('-------') // void
if files[i]==j:
temp1.append(i)
print (temp1)
result[j]=temp1
return (result)
print(FileOwners.group_by_owners(files))