Q. Write a program to read a list of n integers (positive as well as negative).  Create two new lists, one having all positive numbers  and the other having all negative numbers from the given list.  Print all three lists.


Answer :-


lst = eval( input ("Enter a list :-") )
pos =[]
neg = []

for i in lst :
    if i >= 0 :
        pos.append(i)
    else :
        neg.append( i )

print("Intial List :-", lst )
print("List of Positive Number :-", pos)
print("List of Negative Number :-", neg)

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post