0
Dict(ages) .. output is not in sequence. Can anyone explain..
ages = {"Dave": 24, "Mary": 42, "John": 58} print(type(ages)) print(dict(ages))
4 ответов
+ 6
Dictionaries are not ordered structures. You might get a different output order each time.
+ 6
No, not to be predicted, it's done automatically behind the scenes. There are some tendencies in which Python structures dictionaries, but it's the kind of data series you can't rely on when it comes to ordering.
Simply the question of ordering is irrelevant for dictionaries, they are not suited for order-dependent tasks. For this purpose you have lists or tuples.
Or you may store a tuple as a key, where the first element is a number and the second is the actual key to be considered. And try to build ordering on that... (but this is a serious overwork, I think)
0
each time when execution.. how to predict those outputs.. Is any format ? it follows
0
ya thanks for your answer's