Computer Science, asked by AkshatApurva, 6 months ago

Write a program in python 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.

Answers

Answered by muhamadalihasan50
0

Answer:

Solved???

Explanation:

# Python Program to Put Positive and Negative Numbers in Separate List

NumList = []

Positive = []

Negative = []

Number = int(input("Please enter the Total Number of List Elements : "))

for i in range(1, Number + 1):

   value = int(input("Please enter the Value of %d Element : " %i))

   NumList.append(value)

for j in range(Number):

   if(NumList[j] >= 0):

       Positive.append(NumList[j])

   else:

       Negative.append(NumList[j])

print("Element in Positive List is : ", Positive)

print("Element in Negative List is : ", Negative)

Answered by utsavsinghal
0

Answer:

Explanation:

# Python Program to Put Positive and Negative Numbers in Separate List

NumList = []

Positive = []

Negative = []

Number = int(input("Please enter the Total Number of List Elements : "))

for i in range(1, Number + 1):

  value = int(input("Please enter the Value of %d Element : " %i))

  NumList.append(value)

for j in range(Number):

  if(NumList[j] >= 0):

      Positive.append(NumList[j])

  else:

      Negative.append(NumList[j])

print("Element in Positive List is : ", Positive)

print("Element in Negative List is : ", Negative)

Similar questions