@@ -0,0 +1,1290 @@
+#!/usr/local/bin/python%0A# Code Fights Codefighter Attribute Problem%0A%0A%0Aclass CodeFighter(object):%0A    def __init__(self, username, _id, xp, name):%0A        self.username = username%0A        self._id = _id%0A        self.xp = xp%0A        self.name = name%0A%0A    def __getattr__(self, attribute, default=None):%0A        if default is None:%0A            default = %22%7B%7D attribute is not defined%22.format(attribute)%0A        if attribute not in self.__dir__():%0A            return default%0A        else:%0A            return self.attribute%0A%0A%0Adef codefighterAttribute(attribute):%0A    codefighter = CodeFighter(%22annymaster%22, %221234567%22, %221500%22, %22anny%22)%0A    return getattr(codefighter, attribute)%0A%0A%0Adef main():%0A    tests = %5B%0A        %5B%22_id%22, %221234567%22%5D,%0A        %5B%22age%22, %22age attribute is not defined%22%5D,%0A        %5B%22name%22, %22anny%22%5D,%0A        %5B%22country%22, %22country attribute is not defined%22%5D,%0A        %5B%22I%22, %22I attribute is not defined%22%5D%0A    %5D%0A%0A    for t in tests:%0A        res = codefighterAttribute(t%5B0%5D)%0A        ans = t%5B1%5D%0A        if ans == res:%0A            print(%22PASSED: codefighterAttribute(%7B%7D) returned %7B%7D%22%0A                  .format(t%5B0%5D, res))%0A        else:%0A            print(%22FAILED: codefighterAttribute(%7B%7D) returned %7B%7D, answer: %7B%7D%22%0A                  .format(t%5B0%5D, res, ans))%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Solve Code Fights codefighter attribute problem