So i have a list of heights:
heights = [1, 2, 3, 5, 7, 8, 8, 13]
And im using this function to store each height integer value and its index in the list in a class i called Node.
def initializeNodes(heights):
ans = []
for height in heights:
ans.append(Node(heights.index(height), height))
return ans
But my problem is, because their are two 8's in the list, its giving them both the same first 8 position of 5 in the list:
0 1
1 2
2 3
3 5
4 7
5 8
5 8
7 13
How can i go around this? Thanks!