Skip to content Skip to sidebar Skip to footer

'int' Object Is Not Iterable When I'm Not Trying To Iterate

The following piece of code attempts to create a map that shows the minimum number of moves it would take to get from each square on that map to the specified location. The functio

Solution 1:

The line does try to iterate:

>>> a, b = 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError:'int' object is not iterable

The line

squares_to_check = deque((0, loc))

initialises the deque with the two elements 0 and loc, not with the single element (0, loc). Use

squares_to_check = deque([(0, loc)])

to get the desired result.

Post a Comment for "'int' Object Is Not Iterable When I'm Not Trying To Iterate"