I've spent the bulk of my last two days trying to learn Python. I worked out this script to solve problem 21 of Project Euler.
#!\usr\local\bin\pythonIt takes a few seconds to work, but it does the trick.
def sum(a):
divTot = 0
for k in range(1,a):
if (a%k) == 0:
divTot += k
return divTot
amicableNumbers = []
total = 0
for i in range(0, 10000):
temp = sum(i)
if temp < i:
if (sum(temp) == i):
amicableNumbers.append(i)
amicableNumbers.append(temp)
for k in range(0,len(amicableNumbers)):
total += amicableNumbers[k]
print total