Hi,
I'm a newbie to python. I'm going through the wonderful 'how to think like a computer scientist tutorial' and I've come up with a question that I'm not sure how to get it to add the results at the end. Here's the question and my working so far :)
def sum_of_squares_of_digits(n):
"""
>>> sum_of_squares_of_digits(1)
1
>>> sum_of_squares_of_digits(9)
81
>>> sum_of_squares_of_digits(11)
2
>>> sum_of_squares_of_digits(121)
6
>>> sum_of_squares_of_digits(987)
194
"""
sum = []
squares = []
num = []
index = 0
while n:
num = n % 10
squares = num*num
n = n / 10
sum += squares
print sum
sum_of_squares_of_digits(987)