Recently came into a weird problem. I'm trying to change an item in a tuple I've converted to a list.
But what I had,
paths = [(1,2),(2,3),(2,0)]
plist = []
for pathlist in paths:
for n in range(0, len(pathlist)):
if pathlist[n] == 2:
plist = list(pathlist)
plist[n] = 4
pathlist = tuple(plist)
print(pathlist)
print(paths)
Didn't actually change the value in the list paths
, i.e. it stayed the same as originally, even though I could tell from print(pathlist)
that it had been modified correctly. And I can't remove it and append it because that would offset the for loop. Thanks for your help, guys.