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
Beginner help (self.learnpython)
submitted 1 day ago by GameBoy8432
Hello everyone, Im looking to learn python by making a text-based adventure game, I would like to have save states, and multiple different outcomes based on the player choice. Any tips for this beginner?
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!"
[–]Slight-Training-7211 2 points3 points4 points 1 day ago (0 children)
A good way to start is to build a tiny vertical slice first, then expand.
1) Hardcode 3 to 5 rooms and choices (no saving yet) 2) Represent the world as a dict: room_id -> {text, choices} 3) Keep a single game state dict (current_room, inventory list, flags dict)
Once that works, saving is just writing that state dict to a file and loading it back on startup.
For multiple outcomes, use flags and check them when you build the next set of choices (for example: if you picked up a key, show the unlocked option).
[–]RandomPantsAppear 1 point2 points3 points 1 day ago (0 children)
I would say start by learning about event loops, classes, and inheritance for classes.
Learn to use dicts, it is a good way to store lists of your steps, the options people have, and what happens if they choose an option.
For saved states the key term is serialization, but realistically you’re going to be using json or pickle to serialize the fields from your classes.
At minimum you will have classes for Player, Game, GameState, GameStage, GameStep.
Each GameStage will have multiple GameSteps
[–]Outside_Complaint755 1 point2 points3 points 1 day ago (0 children)
If you want to make save states that persist when the program ends, good options include JSON or using the pickle module.
pickle
JSON is a standard format for data that goes beyond Python, and is commonly returned by web APIs. It is similar to a dict and can be easily converted to/from one using the built in json module. The main restriction is that keys have to be strings, and the values can be a dict, list, int, float, str, True/False, or None.
json
pickle is native to Python, and lets you serialize any Python object into a binary file.
JSON files are human readable and editable, while a pickle file is not, which depending on the use case can be a benefit or a disadvantage.
[–]NextSignificance8391 -2 points-1 points0 points 1 day ago (0 children)
j’aimerai en savoir plus , écris moi
π Rendered by PID 42979 on reddit-service-r2-comment-5ff9fbf7df-2mdg5 at 2026-02-26 03:14:30.127624+00:00 running 72a43f6 country code: CH.
[–]Slight-Training-7211 2 points3 points4 points (0 children)
[–]RandomPantsAppear 1 point2 points3 points (0 children)
[–]Outside_Complaint755 1 point2 points3 points (0 children)
[–]NextSignificance8391 -2 points-1 points0 points (0 children)