title: How to update a global variable from within a function in Python 3?
body: <p>I'm trying to run an optimization step and I want to update a global variable from within a function.  I'm using an optimization script and I want to save the data when there are any updates but I cannot update the global variable from within a function.</p>
  
  <p><strong>Is there a way to update a global variable from within a function call?</strong>  I am making sure not to run the optimization step in parallel so this technically should be ok. </p>
  
  <pre><code>global current_minimum
  current_minimum = 0
  
  def update():
      current_minimum = -0.1
  
  _ = update()
  print(current_minimum)
  # 0
  </code></pre>