Recursion in Python

ยท

1 min read

What is Recursion?

It's a type of program where you get a subroutine to call itself. Recursion Helps to Solve problems more humanly, some mathematical problems can be better solved using recursion.

A Small Example:

def reverse(value):
    if value <= 0:
        print("Done!")
        return

    else:
        for i in range(value):
            print("๐Ÿ’ก", end = "")
        print()
        reverse(value - 2)

reverse(10)

Output:

๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก

๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก

๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก

๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก๐Ÿ’ก

๐Ÿ’ก๐Ÿ’ก

Today is 57 / 100 days in my Python Journey, Please feel free to join here : https://join.replit.com/python

See You Tomorrow...

ย