title: Python program freezes and closes when entering an input?
body: <p>I am currently writing a program which graphs a polynomial and shades the area under the curve between two endpoints using Simpson's 3/8th's rule, and then prints that info on the graph. Currently, the program works properly for one polynomial ("(x - 3) * (x - 5) * (x - 7) + 85") between two endpoints (2 and 9). However, when attempting to have the program accept an input for either the polynomial or either endpoint using the input command, the program freezes and crashes without constructing a graph. This occurs even if the current numbers are re-entered. Below is the code:</p>
  
  <p>Here is the base of the code</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.patches import Polygon
  </code></pre>
  
  <p>Here I define the polynomial to be func(x)</p>
  
  <pre><code>def func(x):
      return (x - 3) * (x - 5) * (x - 7) + 85
  </code></pre>
  
  <p>Here I define the function with which to calculate area under the curve using Simpson's rule</p>
  
  <pre><code>def simpson(function, a, b, n):
      """Approximates the definite integral of f from a to b by the
      composite Simpson's rule, using n subintervals (with n even)"""
  
      if n % 2:
          raise ValueError("n must be even (received n=%d)" % n)
  
      h = (b - a) / n #The first section of Simpson's 3/8ths rule
      s = function(a) + function(b) #The addition of functions over an interval
  
      for i in range(1, n, 2):
          s += 4 * function(a + i * h)
      for i in range(2, n-1, 2):
          s += 2 * function(a + i * h)
  
      return(s * h / 3)
  </code></pre>
  
  <p>Here I define the endpoints between which to integrate</p>
  
  <pre><code>a, b = 2, 9  # integral limits
  </code></pre>
  
  <p>Here are a few more definitions for convenience</p>
  
  <pre><code>x = np.linspace(0, 10) #Generates 100 points evenly spaced between 0 and 10
  y = func(x) #Just defines y to be f(x) so its ez later on
  
  fig, ax = plt.subplots()
  plt.plot(x, y, 'r', linewidth=2)
  plt.ylim(ymin=0)
  
  final_integral = simpson(lambda t:func(t), a, b, 100000)
  </code></pre>
  
  <p>Here I construct the shaded region</p>
  
  <pre><code># Make the shaded region
  ix = np.linspace(a, b)
  iy = func(ix)
  verts = [(a, 0)] + list(zip(ix, iy)) + [(b, 0)]
  poly = Polygon(verts, facecolor='0.9', edgecolor='0.5')
  ax.add_patch(poly)
  </code></pre>
  
  <p>Here I print the integral notation on the graph</p>
  
  <pre><code>plt.text(0.5 * (a + b), 30, r"$\int_a^b f(x)\mathrm{d}x$",
       horizontalalignment='center', fontsize=20)
  </code></pre>
  
  <p>Here I print the area under the curve as calculated by simpson's 3/8ths rule on the graph</p>
  
  <pre><code>ax.text(0.25, 135, r"Using Simpson's 3/8ths rule, the area under the curve is: ", fontsize=20) #r denotes a raw string
  ax.text(0.25, 114, final_integral , fontsize=20) #prints the value of the 
  integral defined using simpson's 3/8ths prior
  </code></pre>
  
  <p>Here I finish constructing the graph</p>
  
  <pre><code>plt.figtext(0.9, 0.05, '$x$')
  plt.figtext(0.1, 0.9, '$y$')
  
  ax.spines['right'].set_visible(False) #no dashes on axis
  ax.spines['top'].set_visible(False) 
  ax.xaxis.set_ticks_position('bottom')
  
  ax.set_xticks((a, b))
  ax.set_xticklabels(('$a$', '$b$'))
  ax.set_yticks([])
  
  plt.show()
  </code></pre>
  
  <p>Yet, when I change the line where the endpoints are defined to read 'a, b = int(input("enter your endpoints in the format 2,9"))  # integral limits', the program <a href="https://i.stack.imgur.com/ZpHLY.jpg" rel="nofollow noreferrer">errors out as shown.</a></p>
  
  <p>Any help would be appreciated. I'm struggling to understand the dilemma, so I appoligize for not providing more info.</p>