i have a class (cls) with 2 main strings (str1, str2) and a list of strings (strlist)
python makes the strlist into a tuple so when i want to append to it i use
tmp=list(strlist)
tmp.append(addToList)
self.list=tmp
may not the best option but its the only one i could make with low knowledge of python
now i make things more complicated i have list of cls (clslist) and i want to add another string to the strlist where str1 = A && str2 = B
how do create a search that will search for a match in the clslist and if found will add the new string to strlist
EDIT 1
class cls ():
def __init__ (self,str1,str2,strlist):
self.str1 = str1
self.str2 = str2
self.strlist = strlist
and the main
def main():
clslist =[]
clslist.append(cls ("aaa","bbb",("123","456"))
i want to find the cls in the clslist where str1 = aaa and str2 = bbb and then add another string to the str list
so i will end up like this ("aaa","bbb",("123","456","789"))
AandB? You also say 'python makes the strlist into a tuple', where and why? Please post your class, otherwise it's very hard to work out what is going on. - Gareth Latty