title: Stopping a loop when value = None
body: <p>I have a function that adds API requests to a list, I would like to loop over the requests until the value of 'next_page' is None. My current code is returning the error:</p>
  
  <blockquote>
    <p>TypeError: can only concatenate str (not "NoneType") to str</p>
  </blockquote>
  
  <p>When I print out my results I see that my function is trying to concatenate a 'None' value - how can I stop it doing this? I've tried adding in another if statement <code>if next_page != 'None':</code> but I am still getting the same result.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>pages = []
  def build_requests(request):
      request = 'https://api.performancehorizon.com' + request
      job = requests.get(request, headers=headers, params=params)
      req = job.json()
  
      hypermedia_np = req['hypermedia']['pagination']['next_page']
  
      pages.append(request)
  
      while hypermedia_np is not None or hypermedia_np != 'None':
          next_page = req['hypermedia']['pagination']['next_page']
          print(next_page)
  
          if next_page != 'None':
              pages.append(next_page)
          job = requests.get('https://api.performancehorizon.com' + next_page, headers=headers, params=params)
          req = job.json()
          hypermedia_np = req['hypermedia']['pagination']['next_page']
      print("Done!")
  </code></pre>