-4

How cab I repeat the raw_input sentence because every time I or the user answers the question written the python say press any key to continue but I want to repeat the question to know if the user want to do any thing else using the programme I wish you can help me.

2 Answers2

1

You can use this simple code for that

x  = raw_input("Enter a command or q to quit")
while ( x != 'q' ) : 
    ## your code goes.
    x  = raw_input("Enter a command or q to quit")

This will recursively ask the user for input until he decides to quit.

PyManiac
  • 474
  • 4
  • 12
-1

You mean something as follows?

bool = True 
while bool:
    input = raw_input(query) #Get raw_input
    if condition: #check if you should end the loop or ask again
        bool = False #end loop
    #your code here

bool is used as a boolean to check if the condition has happened, should call it something else such as run_loop or something like that.

Isdj
  • 1,835
  • 1
  • 18
  • 36