In: Computer Science
Python pls
Create a function party_freq(dicto:dict): this function returns a list inside tuple that how many times each person party in the day.
For example
def party_freq(dicto:dict) -> [(str,{(int,int,int): int})]:
#code here
input
dict1 ={'fire1': {(2000,5,20,480) : ('Aaron', 25, 300, ( 0,
300)),
(2000,5,20,720) : ('Baily', 45, 1500, (1500,500)),
(2000,5,21,490) : ('Aaron', 35, 500, (1300,500)) },
'fire2': {(2000,5,20,810) : ('Baily', 45, 1400, (600,1600)),
(2000,5,20,930) : ('Baily', 43, 1800, ( 0, 0)) }}
output
[('Aaron', {(2000,5,20): 1, (2000,5,21): 1}), ('Baily', {(2000,5,20): 3})]
import typing
def party_freq(dicto:dict) -> [(str,{(int,int,int):
int})]:
data=[]
for i in dicto:
for day in dicto[i]:
date=(day[0],day[1],day[2])
names=dicto[i][day]
name=names[0]
found=False
for j in data:
if j[0]==name:
found=True
if date in j[1]:
j[1][date]+=1
else:
j[1][date]=1
if not found:
data.append((name,{date:1}))
return data