-3

Can anyone help please , here is the erreur code : TypeError: object of type 'map' has no len() #4

entropy = (map(lambda x: x.get_entropy(), pe.sections))
res['SectionsMeanEntropy'] = sum(entropy) /  float(len(list(entropy)))
Mechanic Pig
  • 6,756
  • 3
  • 10
  • 31
  • It cannot be reproduced because the map object in your code has been converted to a list through `list`. – Mechanic Pig Jun 26 '22 at 14:43
  • I changed it into : `res['SectionsMeanEntropy'] = sum(entropy) / float(len(entropy))` But I got an other erreur of : object of type 'map' has no len() – El mehdi Laaziri Jun 26 '22 at 14:45
  • This is consistent with the error described in your question, not **another** error. But the code in your problem description will not get this error. – Mechanic Pig Jun 26 '22 at 14:51

1 Answers1

1

Just convert entropy to a list so you can use the len function on it

entropy = list(map(lambda x: x.get_entropy(), pe.sections))
res['SectionsMeanEntropy'] = sum(entropy) / float(len(entropy))
The Thonnu
  • 3,578
  • 2
  • 8
  • 30