I need to print each element with its atomic number and weight each on a separate line, with a colon between the name and atomic number and weight, however, it prints each three times, I understand why but have no idea how to remedy it. Help
Here is the code I used:
elements = [['beryllium', 4, 9.012], ['magnesium', 12, 24.305], ['calcium', 20, 40.078], ['strontium', 38, 87.620], ['barium', 56, 137.327], ['radium', 88, 266.000]]
for x in elements:
for i in x:
print str(x[0]), ':', str(x[1]), str(x[2])
for i in x:line? It seems to do nothing except make the code repeat three times. Remove that, that's all.stron each item that you want toprint. Doingprint x[0], ':', x[1], x[2]would work fine.