On 14/06/21 4:19 am, BlindAnagram wrote:
Am I missing the obvious way to obtain the value (or the key) from a dictionary that is known to hold only one item?
v = d.popitem()[1]
More importantly, is there a good reason why we don't have d.pop() for dictionaries?
My guess is because it's not generally useful to get an arbitrary value from a dict without its corresponding key. Hence the existence of popitem(). -- Greg -- https://mail.python.org/mailman/listinfo/python-list