I want to count the number of the result JSON objects: how can I do?
I have this function: (the problem is in "for i in r:")
import urllib
import json
from classes import ricerca_IMDB
def search_IMDB (titolo):
sito='http://www.omdbapi.com/?s='+titolo
r=0
r=json.loads(urllib.urlopen(sito).read())
i=0
filmList = []
try:
for i in r:
filmList.append(ricerca_IMDB(r['Search'][i]['Title'], r['Search'][i]['Year'], r['Search'][i]['imdbID']))
except:
filmList = []
return filmList
tryexcept(never a good idea) and tell us what the traceback is.