Please consider the following code:
i = [1, 2, 3, 5, 8, 13] j = [] k = 0 for l in i: j[k] = l k += 1 print j
The output (Python 2
You could use a dictionary (similar to an associative array) for j
i = [1, 2, 3, 5, 8, 13] j = {} #initiate as dictionary k = 0 for l in i: j[k] = l k += 1 print j
will print :
{0: 1, 1: 2, 2: 3, 3: 5, 4: 8, 5: 13}