I have a dictionary like the one below and I want to find out how many of the values in it are from the value entered by the user.
{'a': ['Sun', 'Jack'], 'b': ['John', 'Sun', 'Sarah'],...
Count how many 'Sun' in dictionary
Expected output: 2
>Solution :
You can use sum.
dct = {'a': ['Sun'], 'b': ['John', 'Sun', 'Sarah']}
res = sum('Sun' in lst for lst in dct.values())
print(res)
# 2