You can use generator expressions like this:
gen = (x for x in xyz if x not in a)
for x in gen:
print(x)
More Related Contents:
- Why doesn’t this python code run infinite times? [closed]
- One line recursive loop in python
- How to do for loop through all items of a list except the first [duplicate]
- Why does python use ‘else’ after for and while loops?
- Is it possible to implement a Python for range loop without an iterator variable?
- Python: How to keep repeating a program until a specific input is obtained? [duplicate]
- How do I loop through a list by twos? [duplicate]
- Are infinite for loops possible in Python? [duplicate]
- Why does a for-loop with pop-method (or del statement) not iterate over all list elements [duplicate]
- Converting for loops to while loops in python
- Python nested looping Idiom
- Understanding for loops in Python
- Using a loop to create and assign multiple variables (Python) [duplicate]
- How to increment variable names/Is this a bad idea [duplicate]
- Is it possible to make a `for` loop without an iterator variable? (How can I make make code loop a set number of times?)
- How can I make sense of the `else` clause of Python loops?
- for or while loop to do something n times [duplicate]
- Modifying a list while iterating when programming with python [duplicate]
- Skip over a value in the range function in python
- Creating a Python list comprehension with an if and break
- Strange result when removing item from a list while iterating over it in Python
- How to test multiple variables for equality against a single value?
- How to write inline if statement for print?
- What is the difference between i = i + 1 and i += 1 in a ‘for’ loop? [duplicate]
- python: read json and loop dictionary
- what is the difference between return and break in python?
- Is there a “do … until” in Python? [duplicate]
- Updating a value in a pandas dataframe in an iterrows loop
- Pythonic way to avoid “if x: return x” statements
- Python: check if an object is a sequence