Me estoy haciendo un "TypeError: no se puede deshacer las maletas no iterable int objeto"

Jayan Paliwal:

Estoy teniendo algunos problemas. Yo estaría muy agradecido si alguien por favor me ayude a cabo.

Este es el código:

def next1(n1, r1, c1, grid1):
    p_x, p_y = 0 # >>> TypeError: cannot unpack non-iterable int object
    for i in range(0, n1):
        for x in range(0, n1):
            if grid1[i][x] == "p":
                p_x = i
                p_y = x
    diff_x = abs(r1-p_x)
    diff_y = abs(c1-p_y)
    if diff_x > diff_y:
        if r1-p_x > 0:
            return "UP"
        else:
            return"DOWN"
    else:
        if c1-p_y > 0:
            return"LEFT"
        else:
            return"RIGHT"


n = int(input())
r, c = [int(i) for i in input().strip().split()]
grid = []
for i in range(0, n):
    grid.append(list(input()))
grid[r][c] = "m"
print(next1(n, r, c, grid)) # >>> TypeError: cannot unpack non-iterable int object

Este es el error exacto:

    Traceback (most recent call last):
      File "C:/Users/DELL/PycharmProjects/start/bot.py", line 28, in <module>
        print(next1(n, r, c, grid))<br/>
      File "C:/Users/DELL/PycharmProjects/start/bot.py", line 2, in next1
        p_x, p_y = 0
    TypeError: cannot unpack non-iterable int object

¿Cómo puedo solucionar este error?

Andbdrew:

tratar px = py = 0en esa línea en su lugar (o simplemente definir esos valores en declaraciones por separado)

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=364827&siteId=1
Recomendado
Clasificación