Hi I want to add numbers 1-n using while :
Fore example: if n is 3 I want to print 6
6 means: 3+2+1 (but I don’t want to show 3+2+1, I just want to show 6 in my result)
n = int(input())
while n>0:
I don’t know what I have to type after while n>0:
I’m new in Python and also I’m not good at English. Please help me. Thank you.
>Solution :
n = int(input())
my_sum = 0
while n > 0:
my_sum += n
n -= 1
print(my_sum)