I'm new to Python, couldn't figure out the following syntax,
item = [0,1,2,3,4,5,6,7,8,9] for element in item: if not element: pass print(element) this gives me all of these element, it make sense as Pass is skip this step to next one
however if I use continue I will get the following
item = [0,1,2,3,4,5,6,7,8,9] for element in item: if not element: continue print(element) [1,2,3,4,5,6,7,8,9] Can someone tell me why don't I get '0'? Is 0 not in the list?
continueskips the rest of the loop body and continues with the next iteration of the loop.passdoes nothing at all.pass/continueconundrum which has been answered, what are you trying to achieve? There may be better ways to scan the list and produce the desired output (e.g.filter(None, item))