Nov-22-2017, 11:39 AM
Sometimes the error is on the line before the line on which it indicates, i.e. on the line before that line254. I would guess you have problem with the closing parenthesis of the dict. here is the whole code with dict created in the code, not using json.
output
periodic_table = { "H": { "type": "Nonmetal", "mass": 1.008, "number": 1, "radioactive": False, "name": "Hydrogen" }, "He": { "type": "Noble Gas", "mass": 4.003, "number": 2, "radioactive": False, "name": "Helium" }, "Li": { "type": "Alkali Metal", "mass": 6.941, "number": 3, "radioactive": False, "name": "Lithium" }, "Be": { "type": "Alkaline Earth", "mass": 9.012, "number": 4, "radioactive": False, "name": "Beryllium" }, "B": { "type": "Semimetal", "mass": 10.811, "number": 5, "radioactive": False, "name": "Boron" }, "C": { "type": "Nonmetal", "mass": 12.011, "number": 6, "radioactive": False, "name": "Carbon" }, "N": { "type": "Nonmetal", "mass": 14.007, "number": 7, "radioactive": False, "name": "Nitrogen" }, "O": { "type": "Nonmetal", "mass": 15.999, "number": 8, "radioactive": False, "name": "Oxygen" }, "F": { "type": "Halogen", "mass": 18.998, "number": 9, "radioactive": False, "name": "Flourine" }, "Ne": { "type": "Noble Gas", "mass": 39.948, "number": 18, "radioactive": False, "name": "Argon" }, "Na": { "type": "Alkali Metal", "mass": 22.99, "number": 11, "radioactive": False, "name": "Sodium" }, "Mg": { "type": "Alkaline Earth", "mass": 24.305, "number": 12, "radioactive": False, "name": "Magnesium" }, "Al": { "type": "Basic Metal", "mass": 26.982, "number": 13, "radioactive": False, "name": "Aluminium" }, "Si": { "type": "Semimetal", "mass": 28.086, "number": 14, "radioactive": False, "name": "Silicon" }, "P": { "type": "Nonmetal", "mass": 30.974, "number": 15, "radioactive": False, "name": "Phosphorus" }, "S": { "type": "Nonmetal", "mass": 32.066, "number": 16, "radioactive": False, "name": "Sulphur" }, "Cl": { "type": "Halogen", "mass": 35.453, "number": 17, "radioactive": False, "name": "Chlorine" }, "K": { "type": "Alkali Metal", "mass": 39.098, "number": 19, "radioactive": False, "name": "Potassium" }, "Ca": { "type": "Alkaline Earth", "mass": 40.078, "number": 20, "radioactive": False, "name": "Calcium" }, "Sc": { "type": "Transistion Metal", "mass": 44.956, "number": 21, "radioactive": False, "name": "Scandium" }, "Ti": { "type": "Transistion Metal", "mass": 47.867, "number": 22, "radioactive": False, "name": "Titanium" }, "V": { "type": "Transistion Metal", "mass": 50.942, "number": 23, "radioactive": False, "name": "Vanadium" }, "Cr": { "type": "Transistion Metal", "mass": 51.996, "number": 24, "radioactive": False, "name": "Chromium" }, "Mn": { "type": "Transistion Metal", "mass": 54.938, "number": 25, "radioactive": False, "name": "Manganese" }, "Fe": { "type": "Transistion Metal", "mass": 55.845, "number": 26, "radioactive": False, "name": "Iron" }, "Co": { "type": "Transistion Metal", "mass": 58.693, "number": 27, "radioactive": False, "name": "Cobalt" }, "Ni": { "type": "Transistion Metal", "mass": 58.693, "number": 28, "radioactive": False, "name": "Nickel" }, "Cu": { "type": "Transistion Metal", "mass": 63.546, "number": 29, "radioactive": False, "name": "Copper" }, "Zn": { "type": "Transistion Metal", "mass": 65.38, "number": 30, "radioactive": False, "name": "Zinc" }, "Ga": { "type": "Basic Metal", "mass": 69.723, "number": 31, "radioactive": False, "name": "Gallium" }, "Ge": { "type": "Semimetal", "mass": 72.631, "number": 32, "radioactive": False, "name": "Germanium" }, "As": { "type": "Semimetal", "mass": 74.922, "number": 33, "radioactive": False, "name": "Arsenic" }, "Se": { "type": "Nonmetal", "mass": 78.972, "number": 34, "radioactive": False, "name": "Selenium" }, "Br": { "type": "Halogen", "mass": 79.904, "number": 35, "radioactive": False, "name": "Bromine" }, "Kr": { "type": "Noble Gas", "mass": 84.798, "number": 36, "radioactive": False, "name": "Krypton" }, "Rb": { "type": "Alkali Metal", "mass": 85.468, "number": 37, "radioactive": False, "name": "Rubidium" }, "Sr": { "type": "Alkaline Earth", "mass": 87.62, "number": 38, "radioactive": False, "name": "Strontium" }, "Y": { "type": "Transistion Metal", "mass": 88.906, "number": 39, "radioactive": False, "name": "Yttrium" }, "Zr": { "type": "Transistion Metal", "mass": 91.224, "number": 40, "radioactive": False, "name": "Zirconium" }, "Nb": { "type": "Transistion Metal", "mass": 92.906, "number": 41, "radioactive": False, "name": "Niobium" }, "Mo": { "type": "Transistion Metal", "mass": 95.95, "number": 42, "radioactive": False, "name": "Molybdenum" }, "Tc": { "type": "Transistion Metal", "mass": 98.907, "number": 43, "radioactive": True, "name": "Technetium" }, "Ru": { "type": "Transistion Metal", "mass": 101.07, "number": 44, "radioactive": False, "name": "Ruthenium" }, "Rh": { "type": "Transistion Metal", "mass": 102.906, "number": 45, "radioactive": False, "name": "Rhodium" }, "Pd": { "type": "Transistion Metal", "mass": 106.42, "number": 46, "radioactive": False, "name": "Palladium" }, "Ag": { "type": "Transistion Metal", "mass": 107.868, "number": 47, "radioactive": False, "name": "Silver" }, "Cd": { "type": "Transistion Metal", "mass": 112.411, "number": 48, "radioactive": False, "name": "Cadmium" }, "In": { "type": "Basic Metal", "mass": 114.818, "number": 49, "radioactive": False, "name": "Indium" }, "Sn": { "type": "Basic Metal", "mass": 118.711, "number": 50, "radioactive": False, "name": "Tin" }, "Sb": { "type": "Semimetal", "mass": 121.76, "number": 51, "radioactive": False, "name": "Antimony" }, "Te": { "type": "Semimetal", "mass": 127.6, "number": 52, "radioactive": False, "name": "Tellurium" }, "I": { "type": "Halogen", "mass": 126.904, "number": 53, "radioactive": False, "name": "Iodine" }, "Xe": { "type": "Noble Gas", "mass": 131.294, "number": 54, "radioactive": False, "name": "Xenon" }, "Cs": { "type": "Alkali Metal", "mass": 132.905, "number": 55, "radioactive": False, "name": "Cesium" }, "Ba": { "type": "Alkaline Earth", "mass": 137.328, "number": 56, "radioactive": False, "name": "Barium" }, "La": { "type": "Lanthanide", "mass": 138.905, "number": 57, "radioactive": False, "name": "Lanthanum" }, "Ce": { "type": "Lanthanide", "mass": 140.116, "number": 58, "radioactive": False, "name": "Cerium" }, "Pr": { "type": "Lanthanide", "mass": 140.908, "number": 59, "radioactive": False, "name": "Praseodymium" }, "Nd": { "type": "Lanthanide", "mass": 144.242, "number": 60, "radioactive": False, "name": "Neodymium" }, "Pm": { "type": "Lanthanide", "mass": 144.913, "number": 61, "radioactive": True, "name": "Prometheum" }, "Sm": { "type": "Lanthanide", "mass": 150.36, "number": 62, "radioactive": False, "name": "Samarium" }, "Eu": { "type": "Lanthanide", "mass": 151.964, "number": 63, "radioactive": False, "name": "Europium" }, "Gd": { "type": "Lanthanide", "mass": 157.25, "number": 64, "radioactive": False, "name": "Gadolinium" }, "Tb": { "type": "Lanthanide", "mass": 158.925, "number": 65, "radioactive": False, "name": "Terbuim" }, "Dy": { "type": "Lanthanide", "mass": 162.5, "number": 66, "radioactive": False, "name": "Dysprosium" }, "Ho": { "type": "Lanthanide", "mass": 164.93, "number": 67, "radioactive": False, "name": "Holmium" }, "Er": { "type": "Lanthanide", "mass": 167.259, "number": 68, "radioactive": False, "name": "Erbium" }, "Tm": { "type": "Lanthanide", "mass": 168.934, "number": 69, "radioactive": False, "name": "Thulium" }, "Yb": { "type": "Lanthanide", "mass": 173.055, "number": 70, "radioactive": False, "name": "Ytterbium" }, "Lu": { "type": "Lanthanide", "mass": 174.967, "number": 71, "radioactive": False, "name": "Lutetium" }, "Hf": { "type": "Transistion Metal", "mass": 178.49, "number": 72, "radioactive": False, "name": "Hafnium" }, "Ta": { "type": "Transistion Metal", "mass": 180.948, "number": 73, "radioactive": False, "name": "Tantalum" }, "W": { "type": "Transistion Metal", "mass": 183.84, "number": 74, "radioactive": False, "name": "Tungsten" }, "Re": { "type": "Transistion Metal", "mass": 186.207, "number": 75, "radioactive": False, "name": "Rhenium" }, "Os": { "type": "Transistion Metal", "mass": 190.23, "number": 76, "radioactive": False, "name": "Osmium" }, "Ir": { "type": "Transistion Metal", "mass": 192.217, "number": 77, "radioactive": False, "name": "Iridium" }, "Pt": { "type": "Transistion Metal", "mass": 195.085, "number": 78, "radioactive": False, "name": "Platinum" }, "Au": { "type": "Transistion Metal", "mass": 196.967, "number": 79, "radioactive": False, "name": "Gold" }, "Hg": { "type": "Transistion Metal", "mass": 200.592, "number": 80, "radioactive": False, "name": "Mercury" }, "Tl": { "type": "Basic Metal", "mass": 204.383, "number": 81, "radioactive": False, "name": "Thallium" }, "Pb": { "type": "Basic Metal", "mass": 207.2, "number": 82, "radioactive": False, "name": "Lead" }, "Bi": { "type": "Basic Metal", "mass": 208.98, "number": 83, "radioactive": True, "name": "Bismuth" }, "Po": { "type": "Semimetal", "mass": 208.982, "number": 84, "radioactive": True, "name": "Polonium" }, "At": { "type": "Halogen", "mass": 209.987, "number": 85, "radioactive": True, "name": "Astatine" }, "Rn": { "type": "Noble Gas", "mass": 222.018, "number": 86, "radioactive": True, "name": "Radon" }, "Fr": { "type": "Alkali Metal", "mass": 223.02, "number": 87, "radioactive": True, "name": "Francium" }, "Ra": { "type": "Alkaline Earth", "mass": 226.025, "number": 88, "radioactive": True, "name": "Radium" }, "Ac": { "type": "Actinide", "mass": 227.028, "number": 89, "radioactive": True, "name": "Actinium" }, "Th": { "type": "Actinide", "mass": 232.038, "number": 90, "radioactive": True, "name": "Thorium" }, "Pa": { "type": "Actinide", "mass": 231.036, "number": 91, "radioactive": True, "name": "Protactinium" }, "U": { "type": "Actinide", "mass": 238.029, "number": 92, "radioactive": True, "name": "Uranium" }, "Np": { "type": "Actinide", "mass": 237.048, "number": 93, "radioactive": True, "name": "Neptunium" }, "Pu": { "type": "Actinide", "mass": 244.064, "number": 94, "radioactive": True, "name": "Plutonium" }, "Am": { "type": "Actinide", "mass": 243.061, "number": 95, "radioactive": True, "name": "Americium" }, "Cm": { "type": "Actinide", "mass": 247.07, "number": 96, "radioactive": True, "name": "Curium" }, "Bk": { "type": "Actinide", "mass": 247.07, "number": 97, "radioactive": True, "name": "Berkelium" }, "Cf": { "type": "Actinide", "mass": 251.08, "number": 98, "radioactive": True, "name": "Californium" }, "Es": { "type": "Actinide", "mass": 254, "number": 99, "radioactive": True, "name": "Einsteinium" }, "Fm": { "type": "Actinide", "mass": 257.095, "number": 100, "radioactive": True, "name": "Fermium" }, "Md": { "type": "Actinide", "mass": 258.1, "number": 101, "radioactive": True, "name": "Mendelevium" }, "No": { "type": "Actinide", "mass": 259.101, "number": 102, "radioactive": True, "name": "Nobelium" }, "Lr": { "type": "Actinide", "mass": 262, "number": 103, "radioactive": True, "name": "Lawrencium" }, "Rf": { "type": "Transistion Metal", "mass": 261, "number": 104, "radioactive": True, "name": "Rutherfordium" }, "Db": { "type": "Transistion Metal", "mass": 262, "number": 105, "radioactive": True, "name": "Dubnium" }, "Sg": { "type": "Transistion Metal", "mass": 266, "number": 106, "radioactive": True, "name": "Seaborgium" }, "Bh": { "type": "Transistion Metal", "mass": 264, "number": 107, "radioactive": True, "name": "Bohrium" }, "Hs": { "type": "Transistion Metal", "mass": 269, "number": 108, "radioactive": True, "name": "Hassnium" }, "Mt": { "type": "Transistion Metal", "mass": 268, "number": 109, "radioactive": True, "name": "Meitnerium" }, "Ds": { "type": "Transistion Metal", "mass": 269, "number": 110, "radioactive": True, "name": "Darmstadium" }, "Rg": { "type": "Transistion Metal", "mass": 272, "number": 111, "radioactive": True, "name": "Roetgenium" }, "Cn": { "type": "Transistion Metal", "mass": 277, "number": 112, "radioactive": True, "name": "Copernicium" }, "Nh": { "type": "Basic Metal", "mass": "Unknown", "number": 113, "radioactive": True, "name": "Nihonium" }, "Fl": { "type": "Basic Metal", "mass": 289, "number": 114, "radioactive": True, "name": "Ferovium" }, "Mc": { "type": "Basic Metal", "mass": "Unknown", "number": 115, "radioactive": True, "name": "Moscovium" }, "Lv": { "type": "Basic Metal", "mass": 298, "number": 116, "radioactive": True, "name": "Livermorium" }, "Ts": { "type": "Halogen", "mass": "Unknown", "number": 117, "radioactive": True, "name": "Tennessine" }, "Og": { "type": "Noble Gas", "mass": "Unknown", "number": 118, "radioactive": True, "name": "Oganesson" } } for element in periodic_table.values(): if element['type'].endswith('Metal'): print(element) radioactive_elements = [element['name'] for element in periodic_table.values() if element['radioactive']] print(radioactive_elements) for element in filter((lambda x: x['type'] == 'Nonmetal'), periodic_table.values()): print('{name} : {mass}'.format(**element))
Output:{'mass': 91.224, 'type': 'Transistion Metal', 'number': 40, 'radioactive': False, 'name': 'Zirconium'}
{'mass': 65.38, 'type': 'Transistion Metal', 'number': 30, 'radioactive': False, 'name': 'Zinc'}
{'mass': 6.941, 'type': 'Alkali Metal', 'number': 3, 'radioactive': False, 'name': 'Lithium'}
{'mass': 261, 'type': 'Transistion Metal', 'number': 104, 'radioactive': True, 'name': 'Rutherfordium'}
{'mass': 196.967, 'type': 'Transistion Metal', 'number': 79, 'radioactive': False, 'name': 'Gold'}
{'mass': 266, 'type': 'Transistion Metal', 'number': 106, 'radioactive': True, 'name': 'Seaborgium'}
{'mass': 102.906, 'type': 'Transistion Metal', 'number': 45, 'radioactive': False, 'name': 'Rhodium'}
{'mass': 107.868, 'type': 'Transistion Metal', 'number': 47, 'radioactive': False, 'name': 'Silver'}
{'mass': 200.592, 'type': 'Transistion Metal', 'number': 80, 'radioactive': False, 'name': 'Mercury'}
{'mass': 183.84, 'type': 'Transistion Metal', 'number': 74, 'radioactive': False, 'name': 'Tungsten'}
{'mass': 26.982, 'type': 'Basic Metal', 'number': 13, 'radioactive': False, 'name': 'Aluminium'}
{'mass': 190.23, 'type': 'Transistion Metal', 'number': 76, 'radioactive': False, 'name': 'Osmium'}
{'mass': 262, 'type': 'Transistion Metal', 'number': 105, 'radioactive': True, 'name': 'Dubnium'}
{'mass': 186.207, 'type': 'Transistion Metal', 'number': 75, 'radioactive': False, 'name': 'Rhenium'}
{'mass': 85.468, 'type': 'Alkali Metal', 'number': 37, 'radioactive': False, 'name': 'Rubidium'}
{'mass': 58.693, 'type': 'Transistion Metal', 'number': 28, 'radioactive': False, 'name': 'Nickel'}
{'mass': 63.546, 'type': 'Transistion Metal', 'number': 29, 'radioactive': False, 'name': 'Copper'}
{'mass': 277, 'type': 'Transistion Metal', 'number': 112, 'radioactive': True, 'name': 'Copernicium'}
{'mass': 50.942, 'type': 'Transistion Metal', 'number': 23, 'radioactive': False, 'name': 'Vanadium'}
{'mass': 92.906, 'type': 'Transistion Metal', 'number': 41, 'radioactive': False, 'name': 'Niobium'}
{'mass': 132.905, 'type': 'Alkali Metal', 'number': 55, 'radioactive': False, 'name': 'Cesium'}
{'mass': 269, 'type': 'Transistion Metal', 'number': 108, 'radioactive': True, 'name': 'Hassnium'}
{'mass': 98.907, 'type': 'Transistion Metal', 'number': 43, 'radioactive': True, 'name': 'Technetium'}
{'mass': 180.948, 'type': 'Transistion Metal', 'number': 73, 'radioactive': False, 'name': 'Tantalum'}
{'mass': 204.383, 'type': 'Basic Metal', 'number': 81, 'radioactive': False, 'name': 'Thallium'}
{'mass': 'Unknown', 'type': 'Basic Metal', 'number': 115, 'radioactive': True, 'name': 'Moscovium'}
{'mass': 69.723, 'type': 'Basic Metal', 'number': 31, 'radioactive': False, 'name': 'Gallium'}
{'mass': 114.818, 'type': 'Basic Metal', 'number': 49, 'radioactive': False, 'name': 'Indium'}
{'mass': 207.2, 'type': 'Basic Metal', 'number': 82, 'radioactive': False, 'name': 'Lead'}
{'mass': 'Unknown', 'type': 'Basic Metal', 'number': 113, 'radioactive': True, 'name': 'Nihonium'}
{'mass': 112.411, 'type': 'Transistion Metal', 'number': 48, 'radioactive': False, 'name': 'Cadmium'}
{'mass': 192.217, 'type': 'Transistion Metal', 'number': 77, 'radioactive': False, 'name': 'Iridium'}
{'mass': 39.098, 'type': 'Alkali Metal', 'number': 19, 'radioactive': False, 'name': 'Potassium'}
{'mass': 178.49, 'type': 'Transistion Metal', 'number': 72, 'radioactive': False, 'name': 'Hafnium'}
{'mass': 88.906, 'type': 'Transistion Metal', 'number': 39, 'radioactive': False, 'name': 'Yttrium'}
{'mass': 269, 'type': 'Transistion Metal', 'number': 110, 'radioactive': True, 'name': 'Darmstadium'}
{'mass': 264, 'type': 'Transistion Metal', 'number': 107, 'radioactive': True, 'name': 'Bohrium'}
{'mass': 55.845, 'type': 'Transistion Metal', 'number': 26, 'radioactive': False, 'name': 'Iron'}
{'mass': 118.711, 'type': 'Basic Metal', 'number': 50, 'radioactive': False, 'name': 'Tin'}
{'mass': 208.98, 'type': 'Basic Metal', 'number': 83, 'radioactive': True, 'name': 'Bismuth'}
{'mass': 298, 'type': 'Basic Metal', 'number': 116, 'radioactive': True, 'name': 'Livermorium'}
{'mass': 51.996, 'type': 'Transistion Metal', 'number': 24, 'radioactive': False, 'name': 'Chromium'}
{'mass': 272, 'type': 'Transistion Metal', 'number': 111, 'radioactive': True, 'name': 'Roetgenium'}
{'mass': 195.085, 'type': 'Transistion Metal', 'number': 78, 'radioactive': False, 'name': 'Platinum'}
{'mass': 54.938, 'type': 'Transistion Metal', 'number': 25, 'radioactive': False, 'name': 'Manganese'}
{'mass': 58.693, 'type': 'Transistion Metal', 'number': 27, 'radioactive': False, 'name': 'Cobalt'}
{'mass': 101.07, 'type': 'Transistion Metal', 'number': 44, 'radioactive': False, 'name': 'Ruthenium'}
{'mass': 47.867, 'type': 'Transistion Metal', 'number': 22, 'radioactive': False, 'name': 'Titanium'}
{'mass': 268, 'type': 'Transistion Metal', 'number': 109, 'radioactive': True, 'name': 'Meitnerium'}
{'mass': 95.95, 'type': 'Transistion Metal', 'number': 42, 'radioactive': False, 'name': 'Molybdenum'}
{'mass': 44.956, 'type': 'Transistion Metal', 'number': 21, 'radioactive': False, 'name': 'Scandium'}
{'mass': 223.02, 'type': 'Alkali Metal', 'number': 87, 'radioactive': True, 'name': 'Francium'}
{'mass': 106.42, 'type': 'Transistion Metal', 'number': 46, 'radioactive': False, 'name': 'Palladium'}
{'mass': 289, 'type': 'Basic Metal', 'number': 114, 'radioactive': True, 'name': 'Ferovium'}
{'mass': 22.99, 'type': 'Alkali Metal', 'number': 11, 'radioactive': False, 'name': 'Sodium'}
['Rutherfordium', 'Radium', 'Seaborgium', 'Tennessine', 'Neptunium', 'Thorium', 'Dubnium', 'Radon', 'Astatine', 'Uranium', 'Copernicium', 'Actinium', 'Oganesson', 'Hassnium', 'Technetium', 'Moscovium', 'Mendelevium', 'Nihonium', 'Darmstadium', 'Bohrium', 'Einsteinium', 'Californium', 'Nobelium', 'Berkelium', 'Prometheum', 'Bismuth', 'Americium', 'Livermorium', 'Roetgenium', 'Plutonium', 'Meitnerium', 'Fermium', 'Lawrencium', 'Francium', 'Curium', 'Ferovium', 'Polonium', 'Protactinium']
Nitrogen : 14.007
Selenium : 78.972
Oxygen : 15.999
Phosphorus : 30.974
Carbon : 12.011
Hydrogen : 1.008
Sulphur : 32.066
Reply