alphanumeric list

yqyq22 yqyq22 at hotmail.com
Tue Mar 15 09:15:53 EDT 2011


On Mar 15, 11:02 am, Laurent Claessens <moky.m... at 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



More information about the Python-list mailing list