An easier way to do this? (spoiler if you're using pyschools for fun)
msarro at gmail.com
Tue Nov 9 20:00:17 CET 2010
I'm working on one of the puzzles on pyschools.com, and am trying to figure
out if I can make my solution a bit more elegant.
for i in range(0, len(numList)):
Below is the problem. Basically you take the last digit of each number in
the list, and add them together.
Write a function: getSumOfLastDigit(numList) that takes in a list of
positive numbers and returns the sum of all the last digit in the list.
>>> getSumOfLastDigit([12, 23, 34])
>>> getSumOfLastDigit([2, 3, 4])
>>> getSumOfLastDigit([1, 23, 456])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list