0

This is not the real logic of my program, just a simplified version of it. Any help will be really appreciated.

My question is I am maintaining a state like this:

next_state = (state,self.visited_states)
# where self.visited_states = (False, False)
# I want the state to be in this form ((1,1),(False, False))

I need to change the boolean values to True when one of the state is visited. So I was trying something like this:

self.visited_states[0] = True.

I got an error as follows:

TypeError: 'tuple' object does not support item assignment

1 Answer 1

3

tuple are immutable type you can't modify. In expression:

self.visited_states[0] = True.
        ^
        should not be a tuple

If you wants to change it take visited_states as list.

self.visited_states = [False, False]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.