Sorry if the title is a little vague. I'll explain everything in greater detail here. So let's say I have this code:

```
def function1(k):
    return k * 2

def function2(k):
    return k ** 2

func = 'Square'

for i in range(1, 10):
    if func == 'Multiply':
        function1(i)
    elif func == 'Square':
        function2(i)

```

How can I modify the code above so that the if statement can go outside the loop? It seems unnecessary to check in every iteration the value of `func` since it's not going to change inside. the loop. What I'm looking for is something like this:

```
def function1(k):
    return k * 2

def function2(k):
    return k ** 2

func = 'Square'

if func == 'Multiply':
     f = function1()
elif func == 'Square':
     f = function2()

for i in range(1, 10):
    f(i)

```

Let me know if something isn't clear enough or if what I'm asking isn't possible.