Hi totally new and struggling with a likely simple prob.
I have a for-loop creating values and printing the running total as they're generated.
I need to find a way to print the sum of those running totals (in the case below: 3 + 33 + 333) I have a feeling a nested loop is an option but not sure where it'd go. Am I close? (Thanks)
Here is my code thus far:
def nSum(num):
#calculating values for the variable (num) to the p power:
p = 0
newValue = 0
for i in range(num):
currentVal = num * 10**p
p = p+1
#running total of the curent values:
newValue = currentVal + newValue
print(newValue)
return newValue
print(nSum(3)) #Want nSum to be total of all the newValues from the loop