If you encounter…

IndentationError: unindent does not match any outer indentation level

Solution: There might be spaces mixed in with your tabs. Try replacing all tabs with a few spaces.

[Recursive - NameError: global name ‘xxx’ is not defined][R2]

You run a recursive function like:

class Solution(object):
    def addDigits(self, num):
        """
        :type num: int
        :rtype: int
        """
        s = str(num)
        l = list(s)
        sum = 0
        for digit in l:
            sum += int(digit)

        if len(list(str(sum))) == 1:
            return sum
        else:
            return addDigits(sum)

If you try a test case of input 19, you will get NameError: global name 'addDigits' is not defined.

Solution: change the last line like:

return self.addDigits(sum)