Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def atoms(self, symbol):
- """Return the number of type 'symbol' atoms in the molecule
- Raises:
- KeyError - if the symbol is not in atomic periodic table
- """
- molTest = Molecule(symbol)
- molTest.check_symbols()
- total_symbols = 0
- total_symbols_loop = 0
- molecule_list = self._tokentree()
- for item in molecule_list:
- if len(item[0]) > 1:
- for x in item[0]:
- if x[0] == symbol:
- total_symbols_loop = 0
- total_symbols_loop = total_symbols_loop + x[1]
- total_symbols = total_symbols_loop * item[1]
- else:
- if item[0] == symbol:
- total_symbols = total_symbols + item[1]
- return total_symbols
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement