appending an array in while loop and if condition

n = -12
while n < 15:
    if n < 0:
        dgt = []
        dgt.append(n)
    n = n+1
print(dgt)

I am trying to append all negative values in dgt[] but what I get from this code [-1] which is not my result I want all negative valuse in dgt[] please help me.



from Recent Questions - Stack Overflow https://ift.tt/3xlZCRT
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations