AttributeError: 'list' object has no attribute 'items'