My first function in python

Good morning.
This time I am trying to understand the functions within Python.
As you can see in the image, I have created a function that allows me to take a list and assign a number by which all the elements in the list will be multiplied, but I don’t know why it returns a very large list… some help please . Thank you

Hi
You duplicated your list 3 times here
you need to iterate in this one


import sys

def multi(v,n):
    return v*n

OUT = [multi(i,3) for i in IN[0]]

sincerely
christian.stan

2 Likes

thanks for your answer.
I wonder if it is feasible that the FOR should go inside the function and how it could be…??

1 Like
import sys

def multi(elt,n):
    return [e*n for e in elt]

OUT = multi(IN[0],3)

cordially
christian.stan

2 Likes