creating list n many times
How to define n many empty lists where n is the number of vertices of the given arbitrary graph.
Thanks in advance.
How to define n many empty lists where n is the number of vertices of the given arbitrary graph.
Thanks in advance.
If n
is your number of vertices, you can for instance create a list of n
empty lists as follows:
sage: L = [[] for _ in range(n)]
And then you can access the (empty) list number i
(for i
from 0
to n-1
) using:
sage: L[i]
[]
sage: L[i].append(0)
sage: L[i]
[0]
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2015-10-12 15:45:30 +0100
Seen: 983 times
Last updated: Oct 12 '15
check condition for a list of lists
Plotting successive 3D plots in a for loop (only the last one can be plotted!)
Swap coordinates of list elements
multiple parametric_plot's with for loop
plotting multiple functions from a for loop
Add graphs produced by a for loop?