[Tutor] strategy in dealing with user input
Kent Johnson
kent37 at tds.net
Sat Sep 29 19:06:33 CEST 2007
Robert Jackson wrote:
> I have a few lines of code as follows:
>
> CONFIGFILE = raw_input("Enter config location: ")
> while CONFIGFILE == "":
> CONFIGFILE = raw_input("You must enter configuration file location: ")
>
> Let's say the user hits enter past the initial raw_input request. The user will then be in the while loop. Any subsequent "enters" by the user will result in a brand new line that reads: "You must enter configuration file location: ".
>
> Is there a way to clear out the CURRENT line while in the *while* loop so that even if the user hits enter a few extra times, it'll stay in the SAME line that reads "You must enter a configuration file location: " (and not fill up the screen with the same text over and over)?
CONFIGFILE = raw_input("Enter config location: ")
prompt = "You must enter configuration file location: "
while CONFIGFILE == "":
CONFIGFILE = raw_input(prompt)
prompt = ""
Kent
More information about the Tutor
mailing list