I’m creating a list of files with coordinates and id numbers.
a is just an arbitrary value to space out points. f is a file opened earlier and closed later.
I’m using the code listed below. It should generate 511 points, skipping one point that would’ve originally been the 293rd point. Instead it is skipping 169 points and I cannot figure out why. Any help on this would be greatly appreciated.
id=1
for i in range(0,8,1):
for j in range(0,8,1):
for k in range(0,8,1):
x1=i*a
y1=j*a
z1=k*a
if ((i!=4) & (j!=4) & (k!=4)):
f.write("%4.d 1 4 %4.3f %4.3f %4.3f\n"%(id, x1, y1, z1))
id=id+1
Since you require that
imust be different from4ANDjmust be different from4ANDkmust be different from4, you are skipping all points where ANY of these is4. Useinstead. Equivalently, but probably easier to grasp, you could write
or even better
Edit: Here’s a completely rewritten version of your code: