All about dict in python
dict is a data type in python language
dict have key and value which same is list in C#
create new dict
num = {‘one’: 1, ‘two’: 2, ‘three’: 3}
get dict size
len(num)
get all dict key
num.keys()
get all dict value
num.values()
add new data in dict
num[‘four’] = 4
print for each key and value in dict
for key, val in num.items():
print (key, val)
update value in some key
num[‘one’] = ‘11’
delete dict
num.clear()
https://docs.python.org/3/library/stdtypes.html#mapping-types-dict
for sort key, output is list data type
sorted(num)
for sort value, output is list data type
sorted(num.value)
for sort by key and show all member in dict, output is tuples data type
sorted(num.items(), key=lambda x:x[1])