title: Ape tries to make password generator: "if statement" and "try & except" functions prove too difficult (Python)
body: <p>Basically, I'm attempting to make a password generator. I wanted to make it a bit higher quality than what some of the tutorials I watched suggested, so I tried to allow some user input; I wanted the user to be able to type in a number and let them decide how long they want it to be. So I used an &quot;if statement&quot; alongside &quot;try&quot; and &quot;except&quot; in the event that a user writes a letter or any character other than a number. The code looks as follows:</p>
  <pre><code>print(&quot;How long do you want your password to be?&quot;)
  pass_length = input()
  if pass_length:
      try:
          print(str(get_random_string(int(pass_length))))
      except ValueError:
          while pass_length:
              print(&quot;Error: Please input a whole number integer value.&quot;)
              print(&quot;=============================================================&quot;)
              print(&quot;How long do you want your password to be?&quot;)
              pass_length = input()
              if pass_length == int():
                  break
  </code></pre>
  <p>Now, if the user inputs a number, the program runs smoothly and dispenses a random string. the problem is that for reasons that are probably very obvious to you, dear reader, is whenever I incur the wrath of the except conditions, even if the user inputs a digit, it'll still return the error message. Sorry if I leave important or otherwise significant information out, I'm very daft as you can tell.</p>
  <p>Thanks!</p>