r/pythonhelp • u/heirna • Nov 16 '20
Counting atoms with python
I wish to calculate partial charge in complex (im a chemist)
So my problem is that i have a list : ['H2O','OH','COOH'] for exemple
I need to know the number of occurrences of all atoms. So here 4 for H. My problem is that the number of occurrences is the number of occurrences of the letter describing the atom if no stoechiométric coefficient, and else the number of that coefficient, but the number could appear or not at any place except at position 0.
I don't see how can i make this with python and now i'm quite confused.
Do you have any tips for me?
Thanks for your help and time!
3
Upvotes
1
u/ace6807 Nov 16 '20
Can you give me a few more examples of possible lists and their expected outputs?