import numpy as np
nlevels = 3
count = 0
for p1 in range(nlevels):
for p2 in range(nlevels):
iconfig = np.zeros(nlevels)
iconfig[p1] += 1
iconfig[p2] += 1
print('%s' % str(iconfig))
count+=1
print("Total number of microstates = ",count)
[2. 0. 0.]
[1. 1. 0.]
[1. 0. 1.]
[1. 1. 0.]
[0. 2. 0.]
[0. 1. 1.]
[1. 0. 1.]
[0. 1. 1.]
[0. 0. 2.]
Total number of microstates = 9