I have tried several way to do this, not very clear but it works with one solution combining set and list comprehensions.
thelist=[('Meat', 'Milk'), ('Cake - Cookie',), ('Apple', 'Orange')]
ok=map(lambda z: map(lambda v: v.split(" - ") if " - " in v else v ,z),thelist)
for x in ok:
print tuple(x)#whyyy "".join(x) don't works well but type(x) return list :(
print "map lambda, problem-> uncecessary nested lists and/or tuples "
thelist=[('Meat', 'Milk'), ('Cake - Cookie','z - z'), ('Apple', 'Orange')]
print map(lambda z: map(lambda v: v.split(" - ") if " - " in v else v ,z),thelist)
print "list comprehensions, problem-> doublons"
print [[ tuple(item.split(" - ")) if " - " in item else tup for item in tup] for tup in thelist]
print "sets with list comprehension :)"
[[ newlist.append(tuple(item.split(" - "))) if " - " in item else newlist.append(tup) for item in tup] for tup in thelist]
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...