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)

3 Comments

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

  1. thnk u for this solutions ans awesome and may i help u in future by chance













































    ReplyDelete

Post a Comment

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

Previous Post Next Post