+ 3

what is wrong with this code?

i want that if the input is:"abc", thenthe output will be 6 (a=1, b=2, c=3)(1+2+3=6) https://code.sololearn.com/ccttGLp21Z9f/#py

6th Jun 2018, 6:50 PM
misgav yosef
misgav yosef - avatar
2 Respostas
+ 1
Firstly, you don't call s() Secondly, you put return in for loop, so the loop executes only once You don't have balanced parenthesis - more ( than ) You can't create list from a number use return sum([d[i] for i in x]) instead of loop or in each iteration of loop do a+=d[i] (count sum manually)
6th Jun 2018, 7:18 PM
michal
+ 3
thank you so much. i really need to learn more!
6th Jun 2018, 9:56 PM
misgav yosef
misgav yosef - avatar