title: How to generate dynamic function name and call it using user input in Python
body: <p>I have 10 to 20 function with prefix name same, &amp; I have to call them as per user input, But am not getting how to call them, I tried using below method but it's not working, Can anyone tell me how should I make function callable.</p>
  
  <pre><code>def pattern_1(no):
      print('First Pattern with ' +str(no)+ ' rows')
  
  def pattern_2(no):
      print('Second Pattern with ' +str(no)+ ' rows')
  
  
  rows = eval(input('Enter number of rows: '))
  pattern_no = eval(input('Enter pattern num [1-10]: '))
  
  cust_fun_name = 'pattern_' + str(pattern_no)
  
  print(cust_fun_name) # Here its print pattern_2 but why function is not get invoked
  cust_fun_name()
  </code></pre>
  
  <p>When I run above code am getting below error </p>
  
  <pre><code>Traceback (most recent call last):                                                                                
    File "/home/main.py", line 22, in &lt;module&gt;                                                                      
      cust_fun_name()                                                                                               
  TypeError: 'str' object is not callable
  </code></pre>