Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
molecular mass
n=(input()) s=[] for i in range(len(n)): if n[i]=='(': s.append(-1) if(n[i] == 'C'): s.append(12) if(n[i] == 'H'): s.append(1) if(n[i] == 'O'): s.append(16) if(n[i] >= '2' and n[i] <= '9'): nn = s[-1] s.pop() s.append(nn * int(n[i])) if n[i]==')': total = 0; while(s[-1] != -1): total += s[-1]; s.pop() s.pop() s.append(total) res = 0 while(len(s)>0): res += s[-1]; s.pop(); print(res)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Lab_III_3_01_12_2020
31 dec
あだだだだだだだだだだだだだだだだだだだだだだだだ
Print lists separated by comma
PythonSimpleBook1
Game4
haha
Bmi calculator dictionary
Multinomial Naive Bayes
N. Py
stackse - search stackoverflow differently
Please log in to post a comment.