title: Python pass array into function and use it in json return
body: <p>I have the following python code:</p>
  <pre class="lang-py prettyprint-override"><code>import requests
  
  def requestAPI(url):
    return requests.get(url=url).json()
  
  UselessFact = RequestApi(&quot;https://uselessfacts.jsph.pl/random.json?language=en&quot;)['text']
  </code></pre>
  <p>I wanted to put a try/except on the <code>requestAPI</code> function so it does'nt break the code. I thought about this:</p>
  <pre class="lang-py prettyprint-override"><code>import requests
  
  def requestAPI(url, keys):
    return requests.get(url=url).json() #Here is the struggle with passing the &quot;keys&quot; parameter into the return
  
  UselessFact = RequestApi(&quot;https://uselessfacts.jsph.pl/random.json?language=en&quot;, ['text'])
  </code></pre>
  <p>I could do something like:</p>
  <pre class="lang-py prettyprint-override"><code>import requests
  
  def requestAPI(url):
    try:
      return requests.get(url=url).json() 
  
    except:
      return False
  
  UselessFact = RequestApi(&quot;https://uselessfacts.jsph.pl/random.json?language=en&quot;)['text'] if (condition here) else False
  </code></pre>
  <p>But i think there's a better way of doing this.</p>