Hi when i am copying this complete snippet in python shell it is giving indentation error
import heapq
dict = {4: 'four', 1 : 'one', 3: 'third', 2: 'two', 5:'five'}
h = []
for value in dict:
heapq.heappush(h, value)
for i in range(len(h)):
a = heapq.heappop(h)
print a,' ',dict[a]
but if i copy first block
import heapq
dict = {4: 'four', 1 : 'one', 3: 'third', 2: 'two', 5:'five'}
h = []
for value in dict:
heapq.heappush(h, value)
hit enter and then copy second block
for i in range(len(h)):
a = heapq.heappop(h)
print a,' ',dict[a]
hit enter and it works fine
please guide where indentation problem is happening.