Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Seemingly simple loop
#1
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.
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.
Reply


Messages In This Thread
Seemingly simple loop - by Weber585 - Mar-21-2021, 02:15 AM
RE: Seemingly simple loop - by BashBedlam - Mar-21-2021, 02:17 AM
RE: Seemingly simple loop - by Weber585 - Mar-21-2021, 02:32 AM
RE: Seemingly simple loop - by Larz60+ - Mar-21-2021, 02:23 AM
RE: Seemingly simple loop - by jefsummers - Mar-21-2021, 12:31 PM
RE: Seemingly simple loop - by BashBedlam - Mar-21-2021, 01:28 PM
RE: Seemingly simple loop - by menator01 - Mar-21-2021, 01:42 PM
RE: Seemingly simple loop - by jefsummers - Mar-21-2021, 07:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why does VS want to install seemingly unrelated products? db042190 3 674 Jun-12-2023, 02:47 PM
Last Post: deanhystad
  Simple Variable Saving in Loop DevDev 3 3,062 Mar-09-2021, 07:17 PM
Last Post: Fre3k
  Seemingly unstable GPIO output while executing from RetroPie LouF 6 3,984 Feb-19-2021, 06:29 AM
Last Post: LouF
  simple for loop? gr3yali3n 3 2,560 Sep-22-2020, 05:35 AM
Last Post: buran
  Adding second message to simple loop error PythonGainz 2 2,120 Apr-06-2020, 11:55 AM
Last Post: PythonGainz
  simple key value loop help siten0308 4 2,465 Jun-25-2019, 02:53 PM
Last Post: siten0308
  Simple while loop only works on first attempt jsb83 2 2,042 Jun-20-2019, 08:57 PM
Last Post: jsb83
  .split seemingly gets ignored liquidsnake 8 4,033 Feb-22-2018, 04:46 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020