I would like to give some feedback about ...
From: http://www.checkio.org/mission/restricted-sum/solve/
HTTP\_USER\_AGENT:
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
This is the code I wrote for to return the sum of a list of numbers without using keywords like sum/for/while. Albeit, it's probably pretty sloppy because this is the first time I've tried using recursion, but it keeps failing on checkio([2,2,2,2,2,2]) saying that I returned 14 instead of 12. However, when I've run my code in other consoles (like repl.it and codecademy, it says that it returns 12). Any help or feedback would be awesome!
My Code:
added = 0
counter = 1
def checkio(data):
global added
global counter
finish = len(data)
added += data[counter-1]
if counter < finish:
counter += 1
checkio(data)
return added
Created at: 2014/07/27 16:54; Updated at: 2014/07/27 21:42