how to limit possible input while using raw_input? (also using split) <p>i want to limit the users input in two cases:</p> <p>1.With a string and split, when asking the user to put in two, 2 digit numbers I wrote:</p> <pre><code>x=raw_input("words").split() </code></pre> <p>I want to only enable him to write an input that is two 2 digit numbers, and if he does something else I want to pop an error, and for him to be prompted again, until done right.</p> <p>2.This time an INT when asking the user for a random 4 digit number:</p> <pre><code>y=int(raw_input("words")) </code></pre> <p>I only want to allow (for example) 4 digit numbers, and again if he inputs <code>53934</code> for example I want to be able to write an error explaining he must only enter a 4 digit number, and loop it back until he gets it right.</p> <h1>Thank you, hopefully I explained myself properly.</h1> <p>update so - trying to start simple i decided that at first ill only try to ask the user to type in 8 letters. for example an <code>qwertyui</code> input is acceptable, but <code>sadiuso</code> (7 chars) is not.</p> <p>so i tried working with the syntax you gave me and wrote:</p> <pre><code>y=raw_input("words") if not (len(y) == 8): pop an error </code></pre> <p>but im getting a syntax error on the <code>:</code></p>