[Tutor] Q? One additional query
Rishi Maker
rsmaker@bom7.vsnl.net.in
Fri, 1 Sep 2000 10:38:17 +0530
This is a reply of my own mail
Some one just wrote a script in which b is initialized
b = list(range(len(a)))
I guess My script will be much slower than his script as memory has to be allocated at each loop
Just a point
a=['hello','world','i','am','a','worker']
print a
i=0
x=len(a)-1
b=[]
while i<len(a):
b.insert(i,a[x-i])
i=i+1
print b
####Correction
a=['hello','world','i','am','a','worker']
print a
i=0
x=len(a)-1
b=list(range(len(a)))
while i<len(a):
b[i]=a[x-i]
i=i+1
print b
>
> And Then deng wei wrote .............
>
> > tutorHello:
> > The Python said this is wrong.But I think it's right.Why?
> >
> > # The while practice:
> > a=['hello','world','i','am','a','worker']
> > i=0
> > while i<len(a):
> > b[i]=a[len(a)-i]
> > i=i+1
> > print b
> >
> >
> >
> >
> > DengWei
> > deng@ms.shlftdc.net.cn
> >
> >
> > _______________________________________________
> > Tutor maillist - Tutor@python.org
> > http://www.python.org/mailman/listinfo/tutor
>
> --
> -------------------------------------------------------------------------------
> Signature Follows :-
>
> Rishi Maker |------------Quote Of The Mail----------------|
> Web Developer |The church saves sinners, but science seeks |
> rishim@cyberspace.org |to stop their manufacture. -- Elbert |
> Tel : 91-22-5374892 |Hubbard |
> ICQ UIN :-56551784 | |
> -------------------------------------------------------------------------------
> ----------------The Following has been stolen from fortune cookies-------------
> -------------------------------------------------------------------------------
> | ----:----:----:-----:----:----:----:----:----:----:----:----:|
> --------| guru, n: A computer owner who can read the manual. |-------
> | ----:----:----:-----:----:----:----:----:----:----:----:----:|
> -------------------------------------------------------------------------------
> if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
> printf("Don't Panic!\n");
> exit(42);
> }
> (Arnold Robbins in the LJ of February '95, describing RCS)
> -------------------------------------------------------------------------------
> We are using Linux daily to UP our productivity - so UP yours!
> (Adapted from Pat Paulsen by Joe Sloan)
> -------------------------------------------------------------------------------
> `When you say "I wrote a program that crashed Windows", people just stare at
> you blankly and say "Hey, I got those with the system, *for free*".'
> (By Linus Torvalds)
> -------------------------------------------------------------------------------
> Copyleft --:- ®Ø§hì Måkër -:--
> -------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
Signature Follows :-
Rishi Maker |------------Quote Of The Mail----------------|
Web Developer |I have a hard time being attracted to anyone |
rishim@cyberspace.org |who can beat me up. -- John McGrath, |
Tel : 91-22-5374892 |Atlanta sportswriter, on women weightlifters.|
ICQ UIN :-56551784 | |
-------------------------------------------------------------------------------
----------------The Following has been stolen from fortune cookies-------------
-------------------------------------------------------------------------------
| ----:----:----:-----:----:----:----:----:----:----:----:----:|
--------| guru, n: A computer owner who can read the manual. |-------
| ----:----:----:-----:----:----:----:----:----:----:----:----:|
-------------------------------------------------------------------------------
if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
printf("Don't Panic!\n");
exit(42);
}
(Arnold Robbins in the LJ of February '95, describing RCS)
-------------------------------------------------------------------------------
We are using Linux daily to UP our productivity - so UP yours!
(Adapted from Pat Paulsen by Joe Sloan)
-------------------------------------------------------------------------------
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)
-------------------------------------------------------------------------------
Copyleft --:- ®Ø§hì Måkër -:--
-------------------------------------------------------------------------------