Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

DZone's Guide to

# Python Script To Print Lexicographic Permutation

·
Free Resource

Comment (0)

Save
{{ articles[0].views | formatCount}} Views
```#  This is just a small python snippet to lexicographic print permutation from 0 to 9 .. like
#  0 1 2 3 4 5 6 7 8 9
#  0 1 2 3 4 5 6 7 9 8
#  0 1 2 3 4 5 6 8 7 9
#  0 1 2 3 4 5 6 8 9 7
#  0 1 2 3 4 5 6 9 7 8
#  0 1 2 3 4 5 6 9 8 7
#  0 1 2 3 4 5 7 6 8 9
#  I am just a newbie learning programming with python, so excuse my bad coding ;)

```
import sys
count = 0

for a in range(0,10):
table = [False,False,False,False,False,False,False,False,False,False]
table[a] = True
for b in range(0,10):
if not table[b]:
table[b] = True
for c in range(0,10):
if not table[c]:
table[c] = True
for d in range(0,10):
if not table[d]:
table[d] = True
for e in range(0,10):
if not table[e]:
table[e] = True
for f in range(0,10):
if not table[f]:
table[f] = True
for g in range(0,10):
if not table[g]:
table[g] = True
for h in range(0,10):
if not table[h]:
table[h] = True
for i in range(0,10):
if not table[i]:
table[i] = True
for j in range(0,10):
if not table[j]:
print a,b,c,d,e,f,g,h,i,j
count = count + 1
table[j] = False
table[i] = False
table[h] = False
table[g] = False
table[f] = False
table[e] = False
table[d] = False
table[c] = False
table[b] = False

``````
Topics:

Comment (0)

Save
{{ articles[0].views | formatCount}} Views

Opinions expressed by DZone contributors are their own.