Python calculate many different sum in for loop -


i trying calculate letter value (a = 1, b = 2...z = 26) of input. other characters considered 0 code listed below:

alpha = list('abcdefjhijklmnopqrstuvwxyz') = [] sum1= 0 while true:     b = input()     if b == '':         break     else:         a.append(b.lower()) lst_len = len(a) in range(lst_len):     elem_len = len(a[i])     j in range(elem_len):         if (a[i][j]) in alpha:             num = alpha.index(a[i][j]) + 1             sum1 += num          else:             pass     print sum1 

my question how print sum value of each in loop instead of keep adding previous sums

thank you!

move sum1 = 0 after for in range(lst_len):, gets reset after every time inner loop finishes.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -