lundi 27 juin 2016

Tree strings and constrained search

Script example:

part_id=[1,2,3]
part_name=['Tunn_2dsa','alpha_frfrg','omega_ruryt']
input=['a','b','c','d','TUnn','e','f']        
input_str=str(input)
input_lower = input_str.lower()
split=input_lower.split(',')    
for m in range(len(input)):
var =str(split[m])
if input_lower.find(var) >= 0:
ids = []
ele_name =[]
a=len(ele_name)          
for i in range(len(part_id)):
current_name = str(part_name[i])
current_id = str(part_id[i])
lower_name = current_name.lower()
if lower_name.find(var) >= 0:
ids.append(current_id)
ele_name.append(current_name)
print ele_name
print ids

I search a loop for create a string 'ele_name' to use in other script. in this example I would have

ele_name=['tunn']
part_name=['tunn_2dsa']
part_id=[1]

This method is not running cause the loop put out string [] empty.

Aucun commentaire:

Enregistrer un commentaire