Python program to Print Negative Numbers in Set

# print negative Numbers in a List
# input of list
li=[]
n=int(input("Enter size of list "))
for i in range(0,n):
    e=int(input("Enter element of list "))
    li.append(e)
print("negative numbers in",li,"are: ")
#traversing
for i in li:
    # checking condition
    if i<0:
       print(i, end = " ")

OUTPUT:

Enter size of list 6
Enter element of list 0
Enter element of list -3
Enter element of list 4
Enter element of list -6
Enter element of list -7
Enter element of list -2
negative numbers in [0, -3, 4, -6, -7, -2] are:
-3 -6 -7 -2

Leave a Comment