I have an array:
classes = ["banana","mango","apple"]
I am trying to print this array in a specific format where in each element has to be numbered in a particular sequence. The desired output is as follows:
classes = [{"banana" : 1, "mango" : 2, "apple" : 3}]
I tried using a for loop as follows:
classes = ["banana","mango","apple"]
counter = 0
dat = []
for x in classes:
counter=counter+1
d = x,":", counter
dat.append(d)
print(dat)
While this prints
[('banana', ':', 1), ('mango', ':', 2), ('apple', ':', 3)]
this is far from what I require. Can someone help?