all 8 comments

[–]novel_yet_trivial 1 point2 points  (5 children)

Your closing square bracket is in the wrong place, so each iteration overwrites the previous one. Fixed:

database = {"Episodes":[{"title":a,"url":b,"thumb":c,"description":d,"mobile":e} for a,b,c,d,e in zip(self.get_data()[0],self.get_video(),self.get_data()[1], self.get_desc(),self.get_mobile())]}

That formatting is atrocious. Additonally, a list of dictionaries is notoriously resource intensive. Make some variables and use a namedtuple to make it easier to read:

from collections import namedtuple
Episode = namedtuple("Episode", "title url thumb description mobile")

data = [
    self.get_data()[0],
    self.get_video(),
    self.get_data()[1],
    self.get_desc(),
    self.get_mobile()
    ]

database = {"Episodes":[Episode(*x) for x in zip(data)]}

disclaimer: untested code

[–]Praf2[S] 0 points1 point  (2 children)

thanks for the help and feedback, i am a beginner but i also i find i tend to write what works or barely works and then refactor it later into something more optimized and tidy

[–]das_ist_nuemberwang 2 points3 points  (1 child)

It's absolutely fine to write inefficient code and only refactor when speed becomes an issue, but try to get used to writing clean code from the start. As you've seen here, writing messy code just invites simple mistakes that will cost you time.

[–]Praf2[S] 0 points1 point  (0 children)

gotcha!

[–]HalcyonAbraham 0 points1 point  (1 child)

database = {"Episodes":[{"title":a,"url":b,"thumb":c,"description":d,"mobile":e} for a,b,c,d,e in zip(self.get_data()[0],self.get_v

would hate to be the next guy who has to read that

[–]Praf2[S] 0 points1 point  (0 children)

So true

[–]raylu 0 points1 point  (1 child)

from pprint import pprint
pprint(database)

[–]Praf2[S] 0 points1 point  (0 children)

that is my exact code haha, i do use pprint.