title: How to Reject User Input with Loop if it has Special Characters in Python
body: <p>I'm trying to write a program in Python where the user enters an answer and if it's less than 5 characters or has a special character like !, @, #, $, it's supposed to get kicked and the user tries again.</p>
  <p>It's okay if something like ),(,*,&amp;,^ gets entered, I just can't have !,@,#,$.</p>
  <p>I was wondering if someone could explain it for me better than what my poor Googling found.</p>
  <p>Thanks</p>
  <p>Here's my code:</p>
  <pre><code>while True:
      print(&quot;Without entering any special characters !, @, #, $&quot;)
      answer = input(&quot;Please enter an answer &gt;= 5 characters: &quot;)
      if len(answer) &gt;= 5:
          print(&quot;Your answer was greater than or equal to 5 characters!&quot;)
          print(&quot;Success!&quot;)
          break
      else:
          print(&quot;Please read directions and try again.&quot;)
  </code></pre>