title: Testing Valid Input Python
body: <p>So I have a finished program that accepts an input file with bank account information and parses it up and allows for a few different utilities. </p>
  
  <p>One such utility is adding a transaction to the "database" (just a log file). </p>
  
  <p>The program prompts the user to enter 'w' or 'd' and then an amount (float). This represents a deposit or withdrawal of X amount of money.</p>
  
  <p>I was wondering how to go about making sure that the user entered either 'w' or 'd' AND a correct amount (number).</p>
  
  <p>So, I decided that a while loop with the above condition would work, however I am having trouble getting it work 100%</p>
  
  <p>I initially had:</p>
  
  <pre><code>while input1 is not ("w" or "d")
  </code></pre>
  
  <p>where input1 would be the first input (w or d) the user enters</p>
  
  <p>However, I also want to check that a number exists.</p>
  
  <p>I had the idea of casting the string input to a float, then checking that but I wouldn't know how to checking if that is right since casting and checking the type wouldn't tell me much.</p>
  
  <p>How would I also check that the user entered in some sort of number.</p>
  
  <p>So to reiterate, I would like the program to re-prompt for input if the user did not enter either:</p>
  
  <p>A) A w or d
  B) A number (int/float)</p>
  
  <p>Thanks</p>