[Tutor] declaring list
logesh at iafrica.com
Thu Jan 12 05:03:58 CET 2006
I asked yesterday how we can "declare" an array in python. Thanks Brian
van den Broek and Frank Schley for your responses.
A[None] * n works for me.
To answer Brian's question, I was writing the standard backtracking
procedure to find the permutations of 1..n taken r at a time.
def permutations (n, r):
A, Used = [None] * (r+1), [False] * (n+1)
def choose (m):
if m > r:
for j in range (1, n+1):
if not Used [j]:
Used [j] = True
A[m] = j
Used [j] = False
More information about the Tutor