How can I make many empty lists without manually typing
list1=[] , list2=[], list3=[]
Is there a for loop that will make me 'n' number of such empty lists?
How can I make many empty lists without manually typing
list1=[] , list2=[], list3=[]
Is there a for loop that will make me 'n' number of such empty lists?
A list comprehension is easiest here:
Be wary not to fall into the trap that is:
How about this.
Usage:
You can also add a list of list of list of list... like this too. It won't return any error. But i got no idea what it's use for.
I see that many answers here get you many lists with no names assigned (as elements of a larger list). This may be not always what's needed. It is possible to create multiple empty lists, each with a different name/value, using a tuple:
changing this structure should get you what you want.
Lookup list comprehensions
Now,
listOfLists
has N empty lists in itMore links on list comprehensions:
1 2 3
Hope this helps
If you want to create different lists without a "list of lists", try this: