students = {'palii':('male','170'),
'Minckach':('male','176'),
'ddl':('male','180'),
'Red1ska':('male','188'),
'Sargeras':('male','185'),
'Gerus':('female','160'),
'Liah':('male','183'),
'Chhekan':('female','182'),
'Leshega':('male','186'),
'yurii':('male','187')}
I have this dictionary. How can i delete all the females from it and calculate males average height? Maybe there is a function or something that idk?
I tried using filter()
like
newDict = dict(filter(lambda elem: elem[1] == 'male',students.items()))
But this is not working.
def halfmale(stats):
sum = 0
for key in stats.values():
sum += float(key)
half = sum / len(stats)
print(half)
for value, key in stats.items():
if (key+5>half and key-5<half):
print(value)
Python says that promlem is division by zero in this part