if statements, comparing lists, python -
what doing wrong if statement doesn't recognise if element in equal 0? attempting print ever 0 program prints . , ever 1 #. cheers.
a=[0,0,1,0,1,1,0,1,1,0,0,0,0,1] print(a) in range(len(a)): if a[i]==[0]: print('.', end='') else: print('#', end='') print() bash:
[0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1] ##############
you want
if a[i] == 0: instead of
if a[i] == [0]: you want compare items integer value 0, not single-element list [0].
Comments
Post a Comment