The glob.iglob()-function returns an iterator. How can I most effectively assign its “items” to a list in Python? I want the results in a list so that I can choose a random item with random.choice().
The glob.iglob() -function returns an iterator. How can I most effectively assign its items
Share
You could use
glob.globinstead since it returns a list.To build a list out of an arbitrary iterable, you just use the
listbuiltin: