S
S
Sergo Zar2021-07-27 18:12:20
Python
Sergo Zar, 2021-07-27 18:12:20

Why is None returned?

I tried to make a function to shift the array (its length is always 4) to the right by n units, but for some reason, None is returned instead of the shifted array. What's wrong?

m = [1,2,3,4]

def f(a,n):
    t = [0,1,2,3]
    t[0] = a[3]
    t[1] = a[0]
    t[2] = a[1]
    t[3] = a[2]
    r = False
    if n == 1:
        return a
    f(t,n-1)

k = f(m,2) 
print(k)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-27
@Sergomen

Not just f(t,n-1), butreturn f(t,n-1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question