I have the following for and if condition,for loop followed by an if condition, any suggestions on how can i combine them in one line?
for x in ids:
if x!=12345
I have the following for and if condition,for loop followed by an if condition, any suggestions on how can i combine them in one line?
for x in ids:
if x!=12345
for x in (i for i in ids if i!=12345):
# do stuff
In [37]: ids
Out[37]: [12343, 12344, 12345, 12346, 12347, 12348]
In [38]: for x in (i for i in ids if i!=12345):
....: print x
....:
12343
12344
12346
12347
12348