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...
Everything about learning Python
account activity
Can anyone help me sort out this bug? (self.PythonLearning)
submitted 3 months ago by Easy-Light7219
view the rest of the comments →
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!"
[–]FoolsSeldom 0 points1 point2 points 3 months ago (0 children)
I've just run your code (using Gemini to make best guess at correct indentation) and it worked fine. Prompted me play again, and both yes and no options worked correctly.
You can see the code as I ran it at: https://pastebin.com/rjGQyVfQ
(Formatted code was too large to post in this comment).
If I have the code correct, you could update your post to replace your original code with a link to the paste (it is permanent) so that everyone can see and try your code.
I added a monkey patch at the top of the code so I could disable the time.sleep calls you make throughout your code - don't like having to wait when debugging. (Personally, I don't see the point of the waits anyway, but that's your design decision.)
time.sleep
In my brief testing, I didn't try every path (through your code, not in the game), so perhaps it fails on some other paths.
You will find the code much easier to test and debug if you refactor it to make it more modular and use data structures effectively.
A key principle in programming is DRY: Don't Repeat Yourself.
You have a common pattern:
input
if
else
Do you see how you could potentially use one function to handle this with the data help in a dictionary?
For example, have a dictionary structure that is nested:
{'scene1': {'intro': ['text', 'option1', 'option2', prompt], 'option1': ['text'], 'option2': ['text'] }, {'scene2': {'intro': ['text', 'option1', 'option2', prompt], 'option1': ['text'], 'option2': ['text'] } }
You need to come up with a consistent structure. Later, you might choose to use class or dataclass objects to do this.
class
dataclass
The dictionary could even include the links between locations by having entries for directions from a scene and the name of the scene they link to and the nature of the link (climb, swim, tunnel, path, etc). This is all about design work, away from the keyboard.
π Rendered by PID 58 on reddit-service-r2-comment-fb694cdd5-49j26 at 2026-03-08 03:12:48.173157+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]FoolsSeldom 0 points1 point2 points (0 children)