Array multidimensional python

2

I have a series of data that I would like to organize by title, example;

movies = [
   'movie': [
      'legenda' [
         'dub', 'leg', 'nac'
       ],
      'time': [
        1, 2, 3, 4, 5
      ]
   ]
   ....
]

I've tried dict() with list() and I still can not get any results.

 for movie in soup.find_all(class_="filme"):
    movies.update({'title', movie.h4.a.get_text()})
    for legend in movie.select(".movie-info .leg img"):
        movies.update({'leg', legend.get('alt')})

In this way it will only update what I have, I do not know how to create this multidimensional with python (yet)

    
asked by anonymous 12.09.2016 / 21:18

1 answer

1

You are trying to define a dict as if it were a list. Try before setting the dict with the { } brackets, like this:

movies = {
   'movie': {
      'legenda': ['dub', 'leg', 'nac'],
      'time': [1, 2, 3, 4, 5]
   }
   ....
}

A dict, unlike a list, is always a group of combinations between a key (ex: legenda ) and a value (ex: ['dub', 'leg', 'nac'] )

    
13.09.2016 / 13:56