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)
4 Réponses
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.
0
your code itself isn't understandable then how can solo learn accept it 🥲
0
oh ! yeah
so what wrong with it
help me to fix it
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