class Observable(object):
    def __init__(self):
        self.observers = {}

    def notify_observers(self, action, *args, **kwargs):
        for callback in self.observers.get(action, ()):
            callback(*args, **kwargs)

    def observe(self, action, callback):
        self.observers.setdefault(action, []).append(callback)


class Observable(object):
    def __init__(self):
        self.observers = {}

    def notify_observers(self, action, *args, **kwargs):
        kwargs.setdefault('action', action)
        for callback in self.observers.get(action, ()):
            callback(*args, **kwargs)

    def observe(self, actions, callback):
        if not isinstance(actions, (tuple, list)):
            actions = (actions,)
        for action in actions:
            self.observers.setdefault(action, []).append(callback)

Allow observing more than one action at once
Allow observing more than one action at once

+ 
  class Observable(object):
      def __init__(self):
          self.observers = {}
  
      def notify_observers(self, action, *args, **kwargs):
+         kwargs.setdefault('action', action)
          for callback in self.observers.get(action, ()):
              callback(*args, **kwargs)
  
-     def observe(self, action, callback):
+     def observe(self, actions, callback):
+         if not isinstance(actions, (tuple, list)):
+             actions = (actions,)
+         for action in actions:
-         self.observers.setdefault(action, []).append(callback)
+             self.observers.setdefault(action, []).append(callback)
  
Allow observing more than one action at once
## Code Before:
class Observable(object):
    def __init__(self):
        self.observers = {}

    def notify_observers(self, action, *args, **kwargs):
        for callback in self.observers.get(action, ()):
            callback(*args, **kwargs)

    def observe(self, action, callback):
        self.observers.setdefault(action, []).append(callback)

## Instruction:
Allow observing more than one action at once
## Code After:

class Observable(object):
    def __init__(self):
        self.observers = {}

    def notify_observers(self, action, *args, **kwargs):
        kwargs.setdefault('action', action)
        for callback in self.observers.get(action, ()):
            callback(*args, **kwargs)

    def observe(self, actions, callback):
        if not isinstance(actions, (tuple, list)):
            actions = (actions,)
        for action in actions:
            self.observers.setdefault(action, []).append(callback)
