Here is my code
N = namedtuple("N", ['ind', 'set', 'v'])
def solve():
items=[]
stack=[]
R = set(range(0,8))
for i in range(0,8):
items.append(N(i,R,8))
stack.append(N(0,R-set(range(0,1)),i))
while(len(stack)>0):
node = stack.pop()
print node
print items[node.ind]
items[node.ind].v = node.v
In the last line I cant set the items[node.ind].v value to node.v as I want, and am getting the error
"AttributeError: can't set attribute"
I don't know what's wrong but it must be something based on syntax as using statements like node.v+=1 is also showing same error. I'm new to Python, so please suggest a way to make the above change possible.
items[i].v <8how do I do it, I just tried using a temporary variable to store its value and then use this for comparison liketemp = items[i].vthentemp<8.namedtuple's attributes.items[i].v]<8. I need to know any better alternative like the one in answer using._replace()