Challenge: Separate Positive and Negative Numbers from a List

Using the list comprehension methodology, write code to separate positive and negative numbers from a list.

Let’s assume a list contains positive and negative numbers. Write a program to create two lists—one containing positive numbers and another containing negative numbers:

  • Input: A list that contains positive and negative numbers.
  • Output: Two lists—one containing positive numbers and another containing negative numbers.

Get hands-on with 1200+ tech skills courses.