1my_list = ['Nagendra','Babu','Nitesh','Sathya']
2my_dict = dict()
3for index,value in enumerate(my_list):
4 my_dict[index] = value
5print(my_dict)
6#OUTPUT
7{0: 'Nagendra', 1: 'Babu', 2: 'Nitesh', 3: 'Sathya'}
1>> d = {'a': 'Arthur', 'b': 'Belling'}
2
3>> d.items()
4[('a', 'Arthur'), ('b', 'Belling')]
5
6>> d.keys()
7['a', 'b']
8
9>> d.values()
10['Arthur', 'Belling']
11
1# Python3 program to Convert a
2# list to dictionary
3
4def Convert(lst):
5 res_dct = {lst[i]: lst[i + 1] for i in range(0, len(lst), 2)}
6 return res_dct
7
8# Driver code
9lst = ['a', 1, 'b', 2, 'c', 3]
10print(Convert(lst))
1dict = {"a": 1, "b": 2, "c": 3, "d": 4}
2
3data = list(dict.items())
4an_array = np.array(data)
5
6print(an_array)
7OUTPUT
8[['a' '1']
9 ['b' '2']
10 ['c' '3']
11 ['d' '4']]