Mar-21-2021, 02:15 AM
(This post was last modified: Mar-21-2021, 02:15 AM by Weber585.
Edit Reason: added code tags
)
So I literally just started learning python yesterday, I like to do projects to learn specific things cuz thats just how I learn. I know its probably not the best place to start but I decided to try making a text based explore game like zork. This is the code I have and that all works fine.
edit: thank you to the moderator for changing it. like I said I'm still new to this, I copied my script and it didn't work, tried to alter it and didn't change it. also looking at this I see nowhere to add a tag or that I needed to add that to the script
name = raw_input("Hello, What is your name? ") player = name prompt1 = raw_input("Would you like to play a game " + player + "?").lower() if prompt1 == "yes": print("let's play!") elif prompt1 == "no": print("You're no fun! Goodbye.") else: print("yes or no?")My question is how do I go about looping my else back up to my prompt1 so it asks the question again after an input thats neither "yes" or "no"? I believe what I need is a while true: with indentations of course but then I guess I just can't figure out how to make my else false. I will make the lets play into an input and continue as well but I made it print for this example
edit: thank you to the moderator for changing it. like I said I'm still new to this, I copied my script and it didn't work, tried to alter it and didn't change it. also looking at this I see nowhere to add a tag or that I needed to add that to the script
Larz60+ write Mar-21-2021, 02:06 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts
When properly used indentation will show properly if there.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts
When properly used indentation will show properly if there.