I wrote a program which gets a number n ( > 0) and prints all the numbers with n digits.
def Q(n, index = 0, list = ): if (index == n): print list return startFrom = 0 if (index == 0 and n > 1): startFrom = 1 for i in range(startFrom, 10): list.append(i) Q(n, index + 1, list) list = list.__delitem__(index) Q(2)
When I run the code, I get:
Traceback (most recent call last):
File "py_Q.py", line 16, in ?
File "py_Q.py", line 13, in Q
Q(n, index + 1, list)
File "py_Q.py", line 12, in Q
AttributeError: 'NoneType' object has no attribute 'append'
After the program prints the first number (as list), the list becomes NonType.
Could someone explain me what's happening here???
Thanks in advance!