python - Convert a list into a quadruple tuple sequence -


based on this question, i'm interested in converting list like:

["red", "green", "blue"] 

into tuple sequence of string triple , adding counter (integer):

[("red", "red", "", 0), ("green", "green", "", 1), ("blue", "blue", "", 2)] 

usually i'd write method like:

def list_to_items(lst):     items = []     i,j in enumerate(lst):         items.append((j.upper(), j, "", i))     return items 

is there nicer / more pythonic way of doing this?

[(y.upper(), y, "", x) x, y in enumerate(["red", "green", "blue"])] 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -