Monday 15 September 2014

Python list comprehension with multiple variables -


For example:

I am trying to get a list from a list with a specific output, for example:

  L = [(0, 1, 2, 3, 4, 5), (6, 7, 8, 9, 10, ... etc), (... etc) ] Multi_index = [Entry [0, 3, 4] to enter L # ---- & gt; I know that this specific code is wrong   

I like this if the code above can be output:

  [(0, 3, 4) (6, 9, 10), (... etc)]   

I should show different sub-indexs from each index in the main list, if it is possible thanks, and I am thinking of which code I can use to draw it properly. Thank you.

EDIT: Besides, I am outputting them in a text file, how can I format the rows to display them clearly. Writelines and a different output line, thanks again!

Use:

  Multiple_index = map from operator import item (Madreter (0, 3, 4), L)   

Or understand the list:

  multiple_index = [itemgetter (0, 3, 4) (I)     for L

No comments:

Post a Comment