If you do a google search for how to emulate a do-while loop in Python, you'll be able to see many examples of how to create such a loop. In your case, you'd exit the loop if the text the user inputted was "Exit", otherwise, pass the command through to the device.
Wayne
Please remember to mark helpful responses and to set your question as answered if appropriate.