title: If/else variable assigned before if statement executed
body: <p>The first instance of the <code>number_of_discs</code> receives data from another page and this value is visible in the form. </p>
  
  <pre><code>#####Results Page
  
  @app.route('/results', methods=['GET', 'POST'])
  def results():
          form = SendForm()
  
          number_of_discs = request.args.get('number_of_discs', '')
  </code></pre>
  
  <p>In the below code, If the function <code>form.validate_on_submit()</code> returns <code>False</code>, I want the <code>number_of_discs</code> variable to be reassigned the value that has been typed into the form to amended the original data. </p>
  
  <pre><code>#####Results Page
  
  @app.route('/results', methods=['GET', 'POST'])
  def results():
          form = SendForm()
  
          number_of_discs = request.args.get('number_of_discs', '')
  
          if form.validate_on_submit():
                          try:
                                  models.insert(form)
                          except:
                                  print ("hasn't worked")
                          else:
                                  return redirect(url_for('success'))
          else:
                          number_of_discs = form.number_of_discs.data
  
  
          return render_template(
          'results.html', title='Results', number_of_discs=number_of_discs, form=form
  
      )
  </code></pre>
  
  <p>It works to an extent in that the variable is reassigned whatever is typed into the form. However, my problem now is that when I first load the page, the <code>number_of_discs</code> variable in the <code>else</code> statement seems to be initialized as the default value, rather than the first declaration of the <code>number_of_discs</code> variable (i.e. the data from the other page). So to summarize, the variable in the <code>if</code>/<code>else</code> statement seems to precede the variable assigned before/outside of it.  </p>