0

I am phasing some problem in project at sololearn my code doesn't accept sololearn

# sum of N numbers N = int(input("Enter your number :")) if N < 0 : print ("Enter a positive number ") else : sum = 0 while (N > 0) : sum += sum N -= 1 print ("The sum is : ", sum)

22nd May 2022, 6:37 AM
Wasid Ansari
Wasid Ansari - avatar
4 Answers
0
Currently, you are adding the value in the sum variable to itself which is 0 and will remain 0. Therefore change the line from: sum += sum to sum += N This will add the number N, instead of value in the variable sum.
22nd May 2022, 7:10 AM
Sandeep
Sandeep - avatar
0
your code itself isn't understandable then how can solo learn accept it đŸ„Č
22nd May 2022, 6:47 AM
Davinder Kumar
Davinder Kumar - avatar
0
oh ! yeah so what wrong with it help me to fix it
22nd May 2022, 6:52 AM
Wasid Ansari
Wasid Ansari - avatar
0
– Do not write anything inside input() – Add N to sum not sum to sum – Check the indentation of N -= 1 – Read the task description again and see that you should ONLY output the result
22nd May 2022, 7:14 AM
Lisa
Lisa - avatar