On Mar 15, 2:15 pm, yqyq22 <yqy...@hotmail.com> wrote: > On Mar 15, 11:02 am, Laurent Claessens <moky.m...@gmail.com> wrote: > > > > > > > Le 15/03/2011 09:10, yqyq22 a crit : > > > > Hi all, > > > I would like to put an alphanumeric string like this one > > > EE472A86441AF2E629DE360 in a list, then iterate inside the entire > > > string lenght and change each digit with a random digit. > > > Do u have some suggestion? thanks a lot > > > This can be a way to begin : > > > s="EE472A86441AF2E629DE360" > > for a in s: > > print a > > > The following is a very basic trick to build a list <t> containing the > > elements of the string <s> > > > s="EE472A86441AF2E629DE360" > > t=[] > > for a in s: > > t.append(a) > > > All that you have to change is t.append(a) into something that > > tests if a is a number and append something else in that case. > > > Depending what you want, you can even do > > > s.replace("1","ONE").replace("2","TWO").replace("3","FIVE") > > > This is however far from being random ;) > > > Have good tests > > Laurent > > Laurent thanks a lot very much!!! really appreciated it.. now i have a > good start point thanks again- Hide quoted text - > > - Show quoted text -
Something like that but it append A to each element of the string string = "EE472B" t = [] for x in string[:]: print t.append("A") #i don't want to append A, the final result is EAEA4A7A2ABA # i would like to substitute each element with a random string How i can use the random module in this case? Thanks -- http://mail.python.org/mailman/listinfo/python-list