I am trying to get this code to print numbers descending or ascending to 0 based on user input of an integer. In its current form it is repeatedly printing -1 or 1 depending on positive or negative input.
I want the output to look similar to this.
Please enter an integer:
-6
The sequence is:
-6
-5
-4
-3
-2
-1
0
The sum of the sequence is -21.
Integer = int(input('Please enter an integer: '))
print ('The sequence is:')
if Integer < 0:
while Integer != 0:
New_int = Integer =+ 1
print (New_int)
Integer = Integer =+ New_int
print ('The sum of the sequence is ',Integer)
elif Integer == 0:
print (Integer)
print ('The sum of the sequence is ',Integer)
else:
while Integer != 0:
New_int = Integer =- 1
print (New_int)
Integer = Integer =+ New_int
print ('The sum of the sequence is ',Integer)