2015-03-17 19:25:04 -04:00
|
|
|
try:
|
|
|
|
from collections import OrderedDict
|
|
|
|
except ImportError:
|
|
|
|
try:
|
2016-05-02 07:15:11 -04:00
|
|
|
from ucollections import OrderedDict
|
2015-03-17 19:25:04 -04:00
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
2017-06-10 13:03:01 -04:00
|
|
|
raise SystemExit
|
2015-03-17 19:25:04 -04:00
|
|
|
|
|
|
|
d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
|
2017-03-02 19:23:54 -05:00
|
|
|
print(len(d))
|
2015-03-17 19:25:04 -04:00
|
|
|
print(list(d.keys()))
|
|
|
|
print(list(d.values()))
|
|
|
|
del d["b"]
|
2017-03-02 19:23:54 -05:00
|
|
|
print(len(d))
|
|
|
|
print(list(d.keys()))
|
|
|
|
print(list(d.values()))
|
|
|
|
|
|
|
|
# access remaining elements after deleting
|
|
|
|
print(d[10], d[1])
|
|
|
|
|
|
|
|
# add an element after deleting
|
|
|
|
d["abc"] = 123
|
|
|
|
print(len(d))
|
2015-03-17 19:25:04 -04:00
|
|
|
print(list(d.keys()))
|
|
|
|
print(list(d.values()))
|