2021-11-26

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

No comments:

Post a Comment