No error but still no output

Why can’t this run and give a pattern output, please help. I am a beginner.

def pattern(n):

k = 2 * n - 2

for i in range(0,n):

    for j in range(0,k):
        print(end=" ")

        k = k-1
        for j in range(0,i + 1 ):
            print("*", end=" ")
            print("\r")

            pattern(5)

I can see 2 things:

  1. You are using the variable ‘‘n’’ but you haven’t declared it. So, before you use it, declare it, something like this
    n = 10

  2. You are calling a function pattern and you are passing number 5 as argument, but the funcion is not defined.

Try this tool so see step by step what your code does:
http://pythontutor.com/visualize.html#mode=edit

Make sure the language is Python 3.6