+ 2
Ambiguous python quiz
I was trying to answer this python quiz d = {10: "x", 1:"wx", 2:"yz"} a = d.setdefault(1) b = d.setdefault(3) s = '{}'*len(d) print(s.format(*d)) The answer is 10132. But it depends on the ordering of inserted key in the dictionary. According to the following stack overflow answer the order of insertion of a key in an unordered dictionary is implementation dependent. what's your thoughts? https://stackoverflow.com/questions/5629023/key-order-in-python-dictionaries
1 Respuesta
+ 1
I agree with you. The answer is questionnable as dictionary elements have no guaranteed order.