#!/usr/bin/env python
# My solution to the following challenge: https://redd.it/39ws1x

from datetime import date
from collections import defaultdict

class Todo:
    def __init__(self):
        self.items = defaultdict(list)

    def add_item(self, item, tag):
        self.items[tag].append(item)

    def remove_item(self, item, tag):
        self.items[tag].remove(item)

    def print_all_items(self):
        for (tag, items) in self.items.items():
            print str(tag) + ':'
            for item in items:
                print ' ' + item
            print ''
        
if __name__ == '__main__':
    todo = Todo()
    # I actually need to do this, for real.
    todo.add_item('Get an oil change.', 'Car')
    todo.add_item('Plastidip my wheels.', 'Car')
    todo.add_item('Clean my room.', 'Housework')
    todo.print_all_items()
    todo.remove_item('Get an oil change.', 'Car')
    todo.print_all_items()

@@ -81,16 +81,26 @@
 39ws1x%0A%0A
+import os%0A
 from dat
@@ -154,16 +154,48 @@
 ltdict%0A%0A
+home = os.path.expanduser('~')%0A%0A
 class To
@@ -274,147 +274,878 @@
 def 
-add_item(self, item, tag):%0A        self.items%5Btag%5D.append(item)%0A%0A    def remove_item(self, item, tag):%0A        self.items%5Btag%5D.remove(item)
+__load_items(self):%0A        try:%0A            with open(home + '/.config/todo/list', 'r') as todo:%0A                for item in todo.readline():%0A                    # TODO: Need to figure out a way to store tags and items.%0A                    pass%0A        except IOError:%0A            print 'You do not have any items to load.'%0A%0A    def __save_items(self):%0A        try:%0A            with open(home + '/.config/todo/list', 'w') as todo:%0A                # TODO: Implement saving items.%0A                pass%0A%0A    def add_item(self, item, tag):%0A        self.items%5Btag%5D.append(item)%0A%0A    def remove_item(self, item, tag):%0A        if tag in self.items:%0A            if item in self.items%5Btag%5D:%0A                self.items%5Btag%5D.remove(item)%0A            else:%0A                print %22Item %25s could not be found.%22 %25 item%0A        else:%0A            print 'There is not tag named %25s' %25 tag
 %0A%0A  
@@ -1651,32 +1651,102 @@
 hange.', 'Car')%0A
+    todo.remove_item('x', 'x')%0A    todo.remove_item('x', 'Housework')%0A
     todo.print_a

Add and remove now work with minimal error checking.