Return function not able to return a variable


#1

def first_elts(input_lst):
j=[]
for x in input_lst:
k=j.append(x[0])
print(k)
return(j)
movie_names= first_elts(movie_data)
print(movie_names[0:5])


#2

Variables are just names, it’s values that you return.
Anyway, not sure what you’re asking - describe the situation and what you want to know. Also helps if it’s possible to run your code, so make sure it’s intact in your post.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.