#!/usr/bin/env python

class Subject(object):


    def __init__(self):
        self._observers = []

    def subscribe(self, observer):
        self._observers.append(observer)

    def unsubscribe(self, observer):
        self._observers.remove(observer)


    def notify(self):
        for observer in self._observers:
            observer.updateData()

#!/usr/bin/env python

class Subject(object):


    def __init__(self):
        self._observers = set()

    def subscribe(self, observer):
        self._observers.add(observer)

    def unsubscribe(self, observer):
        if observer in self._observers:
            self._observers.remove(observer)

    def notify(self):
        for observer in self._observers:
            observer.updateData()

change list of subscriber from list to set, before remove a subscriber check if there in subscribers list