Reputation: 111
I have a function in python like this
def lemmma(file):
for i in file:
yield i
This function returns each element in the file
What can I do if I want that the function return a list of elements?
Upvotes: 0
Views: 51
Reputation: 11134
def lemmma(file):
lst=[]
for i in file:
lst.append(i)
return lst
Or even better,
def lemmma(file):
return [i for i in file]
Or,
def lemma(file):
return list(file)
Upvotes: 2