Click here to Skip to main content
15,851,395 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
python program to display equal positive and negative for a given number

Zero should not be displayed.

input:
6
output:
3 2 1 -1 -2 -3

What I have tried:

Python
a = int(input())
for i in range(a):
    b = int(input())
Posted
Updated 27-Feb-22 4:11am

1 solution

Python
a = int(input())
for i in range(a):
    b = int(input()) # you do not require more input here

You should start by finding the mid point of the input number (divide it by 2). You can then use the print function inside your range to display the positive and negative values.
 
Share this answer
 
Comments
Maciej Los 27-Feb-22 10:30am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900