samedi 8 février 2020

Why does the vale of jaunts (specifically the 1st value) change when I'm not updating jaunts at all? I'm just updating the 'o'

start = [2020,0,0,2020]
jaunts = [[2020,0,0,2021],[2021,0,0,2022],[2022,0,0,2023],[2020,1,1,2023],[2021,0,0,2023]]

def gridneighbors(start,jaunts):
    neigh = []
    for o in jaunts:
        new_cell = o
        if start[0]==o[0] and (start[1] == o[1] and start[2] == o[2]):
            new_cell[0]=o[3]
            neigh.append(o)
        elif start[3]==o[3] and (start[1] == o[1] and start[2] == o[2]):
            o[3]=o[0]
            neigh.append(o)
        print(jaunts)
    return neigh

print(gridneighbors(start,jaunts))

output:
[[2021, 0, 0, 2021], [2021, 0, 0, 2022], [2022, 0, 0, 2023], [2020, 1, 1, 2023], [2021, 0, 
0, 2023]]

This is the value of jaunts im getting, the 1st value has changed when ive not even updated it.

Aucun commentaire:

Enregistrer un commentaire