Skip to content

Instantly share code, notes, and snippets.

@bazuzu931
Last active September 12, 2023 09:27
Show Gist options
  • Save bazuzu931/88570a075873ae86da6a07d07bf501dd to your computer and use it in GitHub Desktop.
Save bazuzu931/88570a075873ae86da6a07d07bf501dd to your computer and use it in GitHub Desktop.
Functions
===========================================================================================
ll = ['11', '#22', '33']
if any((c := x).startswith('#') for x in ll):
print('Yes')
===========================================================================================
from collections import Counter
data = [
{"a": 111},
{"a": 222},
{"b": 333},
{"c": 444},
]
def get_dict_key_count(d):
return dict(Counter([k for d in data for k, v in d.items()]))
print(get_dict_key_count(data)) # {'a': 2, 'b': 1, 'c': 1}
===========================================================================================
===========================================================================================
===========================================================================================
===========================================================================================
===========================================================================================
===========================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment