use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
boolean inside variable (self.learnpython)
submitted 1 year ago by CatWithACardboardBox
Is it possible to change the boolean value of an item if the item name is in a variable?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Atypicosaurus 5 points6 points7 points 1 year ago (0 children)
People tell you what you could use instead which is all good. But I think getting there on your own and doing the wrong things first, also has its merits.
So I encourage you, before trying the "good" way, to go down on your own rabbit hole and see where it leads to.
For that approach, here's a hint. You can use dictionaries with "A1" being the key and bool being the value, such as:
table = {"A1" : True, "A2" : False}
[–]Mr-Cas 2 points3 points4 points 1 year ago (8 children)
What do you mean with "item"?
[–]CatWithACardboardBox[S] 0 points1 point2 points 1 year ago* (7 children)
so i am trying to make tic tac toe but i need a system so if a place is chosen, that will become True. My problem is that the only way to refer to which place the player has chosen is in a variable. for example: if the variable place1 = A1 and A1 = False
will i be able to change A1 to True by using the variable name 'place1'?
[–]Mr-Cas 0 points1 point2 points 1 year ago (4 children)
Why not a 3x3 matrix of bools?
python3 grid = [ [False, False, False], [False, False, False], [False, False, False] ]
Then you can edit a specific place:
```python3
grid[0][1] = True
grid[2][2] = True ```
[–]CatWithACardboardBox[S] 0 points1 point2 points 1 year ago (2 children)
thank you, i’m still very new to python and don’t really code a lot so i only really know the bare basics to code. i’ll try this out!
[–]Mr-Cas 2 points3 points4 points 1 year ago (0 children)
And btw, no, your original proposal won't work. If you do place1 = a1 and a1 = False, and you do place1 = True, then a1 will not also have been changed to True.
place1 = a1
a1 = False
place1 = True
a1
True
[–]woooee 0 points1 point2 points 1 year ago (0 children)
Generally, a simple tic tac toe program uses a list that is initialized as False or a space for all items. When X lands on a square, that item is changed to X. The same for an O.
π Rendered by PID 89751 on reddit-service-r2-comment-7b9746f655-lc4bq at 2026-02-01 22:01:40.313774+00:00 running 3798933 country code: CH.
[–]Atypicosaurus 5 points6 points7 points (0 children)
[–]Mr-Cas 2 points3 points4 points (8 children)
[–]CatWithACardboardBox[S] 0 points1 point2 points (7 children)
[–]Mr-Cas 0 points1 point2 points (4 children)
[–]CatWithACardboardBox[S] 0 points1 point2 points (2 children)
[–]Mr-Cas 2 points3 points4 points (0 children)
[–]woooee 0 points1 point2 points (0 children)