Force a raw_input

python

Solution

This is often done with a "loop-and-a-half" construct with a `break` in the middle:

while True:
    title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))
    if title_selection:
        break
    print "Sorry, you have to enter something."

This method gives you an easy opportunity to print a message telling the user what the program expects.

Problem

How would I implement the following: ``` title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string)) if not title: # repeat raw_input ```

Original source