Header Ads

Responsive Ads Here

Question/Solution - 6

 Question



l = [34, 0, -12, -78, 43, 0, 6, -1, 0, 86, -100, 56]

# Negative => [-12, -78, -1, -100]
# Positive => [34, 43, 6,86, 56]
# 0 => 3


  Answer



l = [34, 0, -12, -78, 43, 0, 6, -1, 0, 86, -100, 56]
n = []
p = []
for i in l:
    if i < 0:
        n.append(i)
    elif i > 0:
        p.append(i)    

print(f"Negative => {n}")
print(f"Positive => {p}")  
print(f"0 => {l.count(0)}")

Powered by Blogger.