Skip to main content
1 of 4
janos
  • 111.7k
  • 15
  • 152
  • 391

Something that really hurts readability here is the variable names that shadow the names of Python built-ins: set, len. Find better names instead of these, something descriptive that gives more hints to the reader. The variables val and l could also use better names.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

len = len + 1

This is shorter and better:

len += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]
janos
  • 111.7k
  • 15
  • 152
  • 391