title: (python) How to check the validity of a while loop before letting the user to input things?
body: <pre><code>import random
  
  numberList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king']
  total = 0
  
  while total &lt;= 21:
      output = random.choice(numberList)
      if output == 'jack' or output == 'queen' or output == 'king':
          print(f'({output})')
          output = 10
  
      print(f'you got {output} points')
      total += output
  
      ask_cont = input(f'you now have {total} points, continue? [y/n]: ').lower()
      if ask_cont == 'y':
          continue
      else:
          print(f'game finished. You gain {total} points!')
          break
  else:
      print(f'you lost! points exceeded = {total - 21} points!')
  </code></pre>
  
  <p>I am coding a blackjack game. However, in the while loop (condition: total amount at hand &lt;= 21), when it <strong>exceeded</strong> 21 points, it still ask me to continue (ask_cont variable) or not [y/n] for <strong>ONCE</strong> before code finished and if I type 'n', it just give me the current points (>21) and the 'game finished' statement. How can I fix this? Thank you very much</p>
  
  <p>(also, if there is any way to trim the code please comment, many thanks!)</p>