+ 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
2 Answers
+ 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)
+ 3
thank you so much. i really need to learn more!