1
I have a list of several dictionaries containing registration data:
[{'sex': ’M', 'age': 44}, {'sex': 'F', 'age': 33}, {'sex': ’M', 'age': 55}]
I created separate functions to calculate the average, and the number of female/male people (and also the percentage)
But my problem is in passing the parameter to these functions, and how to go through this list to collect the data (for example, a repeat structure to collect the 'age' data to calculate the average.), as I would do this access?
Ah, in Python 3.8 onwards you can use the operator Walrus and just do
if valor := item.get('idade', 0): ...
– Giovanni Nunes