Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Seemingly simple loop
#2
Here's one way to go about it but if you are going to control input throughout the whole game, I would consider writing a function that would accept a prompt and list or tuple of acceptable answers.

name = input("Hello, What is your name? ")
player = name
print ("Would you like to play a game " + player + "?")
prompt1 = 'BashBedlam was here.'
while prompt1 not in ('yes', 'no', 'y', 'n') :
	prompt1 = input ("yes or no?").lower ()
	if prompt1 == "yes":
		print("let's play!")
	elif prompt1 == "no":
		print("You're no fun! Goodbye.")
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 1,342 Jun-12-2023, 02:47 PM
Last Post: deanhystad
  Simple Variable Saving in Loop DevDev 3 4,044 Mar-09-2021, 07:17 PM
Last Post: Fre3k
  Seemingly unstable GPIO output while executing from RetroPie LouF 6 5,672 Feb-19-2021, 06:29 AM
Last Post: LouF
  simple for loop? gr3yali3n 3 3,365 Sep-22-2020, 05:35 AM
Last Post: buran
  Adding second message to simple loop error PythonGainz 2 2,665 Apr-06-2020, 11:55 AM
Last Post: PythonGainz
  simple key value loop help siten0308 4 3,274 Jun-25-2019, 02:53 PM
Last Post: siten0308
  Simple while loop only works on first attempt jsb83 2 2,645 Jun-20-2019, 08:57 PM
Last Post: jsb83
  .split seemingly gets ignored liquidsnake 8 5,385 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