I've been going through some code challenges. And one struck me in particular. CodeAbbey has a Weighted Sum of Digits challenge. And this was my answer.
# open and read a file, hardcoded numbers, etc. Here is a sample
raw_data = (6, 19, 64, 6527226, 12345146) for number in raw_data:wsd = 0 # Stores sumnumber_list = list(str(number)) # Converts the number into a list.for i, k in enumerate(number_list): # Enumerates each numberwsd += (int(i+1) * int(k)) # Multiplies and adds product to wsdprint(wsd)output >>> 6, 19, 14, 114, 137
Anyone with more experience able to see a better way of getting the sum?