import requests
import simplejson as json


def getbaseurl(service='search', version='1', method='track',
                format='json'):
    """Returns the base URL for a Spotify Web API query"""
    baseurl = "http://ws.spotify.com/{0}/{1}/{2}.{3}"
    return baseurl.format(service, version, method, format)


def search(terms, method='track'):
    if hasattr(terms, '__iter__'):
        sterms = ' '.join(terms)
    else:
        sterms = terms
    base = getbaseurl(method=method)
    r = requests.get(base, params={'q': sterms})
    if r.status_code != requests.codes.ok:
        raise NotImplementedException("There was some problem. Exception"
                "not defined yet")
    data = r.json()
    return data

import requests
try:
    import simplejson as json
except ImportError:
    import json


def getbaseurl(service='search', version='1', method='track',
                format='json'):
    """Returns the base URL for a Spotify Web API query"""
    baseurl = "http://ws.spotify.com/{0}/{1}/{2}.{3}"
    return baseurl.format(service, version, method, format)


def search(terms, method='track'):
    if hasattr(terms, '__iter__'):
        sterms = ' '.join(terms)
    else:
        sterms = terms
    base = getbaseurl(method=method)
    r = requests.get(base, params={'q': sterms})
    if r.status_code != requests.codes.ok:
        raise NotImplementedException("There was some problem. Exception"
                "not defined yet")
    data = r.json()
    return data

Add json module as fallback for simplejson
Add json module as fallback for simplejson

  import requests
+ try:
- import simplejson as json
+     import simplejson as json
+ except ImportError:
+     import json
  
  
  def getbaseurl(service='search', version='1', method='track',
                  format='json'):
      """Returns the base URL for a Spotify Web API query"""
      baseurl = "http://ws.spotify.com/{0}/{1}/{2}.{3}"
      return baseurl.format(service, version, method, format)
  
  
  def search(terms, method='track'):
      if hasattr(terms, '__iter__'):
          sterms = ' '.join(terms)
      else:
          sterms = terms
      base = getbaseurl(method=method)
      r = requests.get(base, params={'q': sterms})
      if r.status_code != requests.codes.ok:
          raise NotImplementedException("There was some problem. Exception"
                  "not defined yet")
      data = r.json()
      return data
  
Add json module as fallback for simplejson
## Code Before:
import requests
import simplejson as json


def getbaseurl(service='search', version='1', method='track',
                format='json'):
    """Returns the base URL for a Spotify Web API query"""
    baseurl = "http://ws.spotify.com/{0}/{1}/{2}.{3}"
    return baseurl.format(service, version, method, format)


def search(terms, method='track'):
    if hasattr(terms, '__iter__'):
        sterms = ' '.join(terms)
    else:
        sterms = terms
    base = getbaseurl(method=method)
    r = requests.get(base, params={'q': sterms})
    if r.status_code != requests.codes.ok:
        raise NotImplementedException("There was some problem. Exception"
                "not defined yet")
    data = r.json()
    return data

## Instruction:
Add json module as fallback for simplejson
## Code After:
import requests
try:
    import simplejson as json
except ImportError:
    import json


def getbaseurl(service='search', version='1', method='track',
                format='json'):
    """Returns the base URL for a Spotify Web API query"""
    baseurl = "http://ws.spotify.com/{0}/{1}/{2}.{3}"
    return baseurl.format(service, version, method, format)


def search(terms, method='track'):
    if hasattr(terms, '__iter__'):
        sterms = ' '.join(terms)
    else:
        sterms = terms
    base = getbaseurl(method=method)
    r = requests.get(base, params={'q': sterms})
    if r.status_code != requests.codes.ok:
        raise NotImplementedException("There was some problem. Exception"
                "not defined yet")
    data = r.json()
    return data
