for i in range(len(sumprop3)):
	for j in range(len(x2)):
		if j==i:
			print x2[j], atomnumber[i:i+8]

For atomnumber[i:i+8] it is printing the range ie [1,2,3,4,5,6,7,8]. I want it to print just [1,8]. How would I do this?

for i in range(min(len(sumprop3), len(x2))):
    print("%s [%s, %s]" % (x2[i],atomnumber[i], atomnumber[i+8]))

Edited 6 Years Ago by pyTony: n/a

for i in range(min(len(sumprop3), len(x2))):
    print("%s [%s, %s]" % (x2[i],atomnumber[i], atomnumber[i+8]))

Thank you!

Do you know why this is printing in duplicate?

print "Propensity value follwed by the range:"
for i in range(len(sumprop3)):
	for j in range(len(x2)):
		if x2[j]==sumprop3[i]:
			print x2[j], list((atomnumber[i],atomnumber[i+8]))

Thank you!

Do you know why this is printing in duplicate?

print "Propensity value follwed by the range:"
for i in range(len(sumprop3)):
	for j in range(len(x2)):
		if x2[j]==sumprop3[i]:
			print x2[j], list((atomnumber[i],atomnumber[i+8]))

Here's the output

Propensity value follwed by the range:
2.2 [49, 57]
1.8 [50, 58]
2.3 [51, 59]
2.1 [52, 60]
2.05 [86, 94]
2.12 [87, 95]
2.12 [87, 95]
2.12 [88, 96]
2.12 [88, 96]
2.37 [89, 97]
2.36 [134, 142]
1.87 [135, 143]
2.27 [172, 180]
2.27 [172, 180]
1.44 [198, 206]
1.23 [199, 207]
1.23 [199, 207]
1.23 [200, 208]
1.23 [200, 208]
1.18 [201, 209]
1.79 [202, 210]
2.08 [203, 211]
2.08 [203, 211]
2.08 [204, 212]
2.08 [204, 212]
2.29 [205, 213]
2.27 [210, 218]
2.27 [210, 218]
This article has been dead for over six months. Start a new discussion instead.