Convert tuple to list and back

I’m currently working on a map editor for a game in pygame, using tile maps. The level is built up out of blocks in the following structure (though much larger): level1 = ( (1,1,1,1,1,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,1,1,1,1,1)) where “1” is a block that’s a wall and “0” is a block that’s empty air. … Read more

How to unzip a list of tuples into individual lists? [duplicate]

This question already has answers here: Closed 9 years ago. Possible Duplicate: A Transpose/Unzip Function in Python I have a list of tuples, where I want to unzip this list into two independent lists. I’m looking for some standardized operation in Python. >>> l = [(1,2), (3,4), (8,9)] >>> f_xxx (l) [ [1, 3, 8], … Read more

How to easily initialize a list of Tuples?

I love tuples. They allow you to quickly group relevant information together without having to write a struct or class for it. This is very useful while refactoring very localized code. Initializing a list of them however seems a bit redundant. var tupleList = new List<Tuple<int, string>> { Tuple.Create( 1, “cow” ), Tuple.Create( 5, “chickens” … Read more