Last active
September 12, 2023 09:27
-
-
Save bazuzu931/88570a075873ae86da6a07d07bf501dd to your computer and use it in GitHub Desktop.
Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=========================================================================================== | |
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