python - Convert a list into a sequence of string triples -


i'd convert list like:

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

into tuple sequence of string triples:

[("red", "red", ""), ("green", "green", ""), ("blue", "blue", "")] 

until use method:

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

but feels bit ugly. there nicer / more pythonic way of doing this?

you can use comprehension:

def list_to_items(lst):     return [(item.upper(), item.title(), '') item in lst] 

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? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -