make a recurring function in python

main.py
def print_numbers(n):
    if n <= 0:
        return
    print(n)
    print_numbers(n-1)
    
print_numbers(5)
110 chars
8 lines

This Python code defines a recursive function print_numbers that prints numbers in descending order from n to 1. This is a simple example of a recurring function in Python using recursion.

related categories

gistlibby LogSnag