Question: I already know how to count down and up using reccurssive function but I cant figure out how to define another function to have spaces in a pattern like this:
[Desired output](https://i.stack.imgur.com/KhIw2.png)

My code for counting down and up:

```
def f(n):
if n==0:
    print (n)  
    return
print (n) 
f(n-1)  
print (n)  

```

Answer: 
```
a = 5 #you can take any value, it will be actually taken from the user
def f(n):
    global a
    if n == 0:
        print(' '*a + str(n))
        return
    print(' '*(a-n), + str(n))
    f(n-1)
    print(' '*(a-n), + str(n))
a = int(input())
f(a)

```
This is probably not exactly what you need. But it gives you an idea :)

As you can see it is based on @Samudra Ganguly's answer

```
def f(n,x):
    if n < 0:
        return
    p(n,x-n)
    f(n-1,x)
    if n !=0:
        p(n,x-n)

def p(m,x):
    print(" ", end = "")
    if x>0:
        p(m,x-1)
    else:
        print(m, end = "\n")

f(8,8)

```

[![enter image description here](https://i.stack.imgur.com/p8LMZ.png)](https://i.stack.imgur.com/p8LMZ.png)

Also you can change the function like this:

```
k=4;

def f(n):
    if n < 0:
        return
    p(n,k-n)
    f(n-1)
    if n !=0:
        p(n,k-n)

def p(m,x):
    print(" ", end = "")
    if x>0:
        p(m,x-1)
    else:
        print(m, end = "\n")

f(k)

```