Код: Выделить всё
class Recursion:
@staticmethod
def recursive(x):
if (x>5):
print (x)
recursive(x - 1)
def main(self):
x = int(input('Enter a number for recursive addition: '))
recursive(x)
Код: Выделить всё
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Recursion import *
>>> a = Recursion()
>>> a.main()
Enter a number for recursive addition: 10
Traceback (most recent call last):
File "", line 1, in
File "/Users/ZycinG/Desktop/Python Practice/Recursion.py", line 9, in main
recursive(x)
NameError: name 'recursive' is not defined
Подробнее здесь: https://stackoverflow.com/questions/360 ... aticmethod