Can someone explain me what's wrong in this code:
import heapq
a = [[1, 2], [0, 4], [3]]
h = []
for index in range(len(a)):
i = 0
while i < len(a[index]):
heapq.heappush(h, a[index][i])
i += 1
print(h)
I want to have smth like that: [0, 1, 2, 3, 4], but when I add 0 it's not becoming [0, 1, 2] but becoming [0, 2, 1].WHY? Thank you in advance!