Your code is not working because you are never changing the n
variable. In your function you’re checking if n > 0
and it will always be
Here is a fix:
n = int(input("?"))
def again_book(self):
if self > 0:
again_book(self - 1)
print(self)
again_book(n)
Another way of doing it is using a while
loop:
n = int(input("?"))
x = 0
while x < n:
print(x)
x += 1
solved i want to print number from 1 to n but after running this code, error “core dumped” occured