I have written the following code for an exercise I was given, nonetheless, when I try to submit it, I get an incorrect answer for my code.
So this is my code:
def problem(n):
my_sum = 0
while my_sum < n:
my_sum = n
my_sum = my_sum + n
print (my_sum)
What they have asked me to code is the following: Write a function problem(n): that adds up the numbers 1 through n and prints out the result. You should use either a 'while' loop or a 'for' loop. Be sure that you check your answer on several numbers n.