I'm trying to write a program to add up number from 1 to n. I've managed to get it to print the numbers several times but not add them all. It keeps on just adding two of the numbers.
My 1st attempt is:
def problem1_3(n):
my_sum = 0
# replace this pass (a do-nothing) statement with your code
while my_sum <= n:
my_sum = my_sum + (my_sum + 1)
print()
print(my_sum)
How can I fix this problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…