I have a dictionary where each keys have multiple values. I am trying to count the total number of values. For example:
key: 1, value: abc, bcd, egf
key: 2, value: asj,asfah,afhs,jhsafh
so, the total number of values are 3+4 = 7 What is the pythonic way to get this count. Thanks
sum(1 for value in value_iterable), and there are several ways you could check if the item was iterable or not, if you could have a list that was that heterogeneous (you shouldn't).dct['k'] = "wrong", instead ofdct['k'] = ["correct"]. guess it is a matter of discipline.