Im creating a list where if a string is in another list, it's assigned a number. After the assigned number, I would like it if it was taken out the loop or "ignored". For example list (abc, ab, c, a, ab, bc)
is searched with ('a','b','c','d')
in that order. Everything with 'a' would get a number then be ignored. Any 'b' with no 'a' would get b's corresponding number. I have something that appends two values if say b and c are together. I would just like b then c ignored in the final list. "values" in my example is a long list where any combination containing A,B,C,D can be found anywhere. I also want everything not found in values (Say E) attached at the end of the list. Any help would be greatly appreciated. Sorry if my example has mistakes
List_Main = []
List_MainNum
a = []
b = []
def sub(x,y):
a.append(text)
b.append(y)
Remain_List = []
textd = [['A','B','C','D','E'], [1,2,3,4,5]]
for text in values:
for i in range(len(textd[1])):
if i==0 and textd[0][0] in text:
List_Main.append(text)
List_MainNum.append(textd[1][0])
elif textd[0][i] in text:
sub(textd[0][i], textd[1][i])
def Lizt(f,g):
List_MainNum.extend(b)
List_Main.extend(a)
Lizt(a,b)
for xyz in values:
if xyz not in List_Main:
Remain_List.append(xyz)
List_Main.extend(Remain_List)
Aucun commentaire:
Enregistrer un commentaire