I have a dictionary in the format of male_name_counts = {male_name: male_name_counts}
, where the KEY is male name and VALUE is the counts of appearance in my data.
I already know the most frequent name: 'highest_male_count' and I want to find all the corresponding keys with the value of the highest count.
I wrote a list comprehension:
top_male_names = [x for male_name_counts[x] == highest_male_count]
Then I got SyntaxError: invalid syntax. I am confused cuz I saw the official document for list comprehension says as long as there is a for with a iterable, it should be fine. I want to know what is wrong with this expression and is it possible to achieve my goal using just list comprehension?