List comprehensions: for and tuple : List Comprehensive « List « Python
- Python
- List
- List Comprehensive
List comprehensions: for and tuple

print [x+y for x in 'spam' for y in 'SPAM']
print [(x,y) for x in range(5) if x%2 == 0 for y in range(5) if y%2 == 1]
Related examples in the same category