You can use itertools.product:
>>> for x,y,z in itertools.product(range(2), range(2), range(3)):
... print x,y,z
...
0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 1 2
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]
- 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]
- Pythonic way to combine for-loop and if-statement
- 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
- 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
- Strange result when removing item from a list while iterating over it in Python
- Why does python use ‘else’ after for and while loops?
- How do I count occurrence of unique values inside a list
- Get the key corresponding to the minimum value within a dictionary
- How to iterate over a list in chunks
- For loop with custom steps in python
- Converting a number to binary with a fixed length
- python: read json and loop dictionary
- Is there a “do … until” in Python? [duplicate]
- Updating a value in a pandas dataframe in an iterrows loop
- List append() in for loop raises exception: ‘NoneType’ object has no attribute ‘append’ [duplicate]
- What is the clojure equivalent of the Python idiom “if __name__ == ‘__main__'”?