Re: [Tutor] most efficient way to do this

2008-02-14 Thread bob gailer
Christopher Spears wrote: > I created a file called arrays.py: > > #!/usr/bin/python > > locations = ["/home/", > "/office/" , > "/basement/" , > "/attic/"] > > Now I want to add the word "chris" on to each element > of the locations list, so I wrote another script > called chris_arrays.py: > > #!/

Re: [Tutor] most efficient way to do this

2008-02-14 Thread Alan Gauld
"Christopher Spears" <[EMAIL PROTECTED]> wrote > from arrays import locations > > add_on = "chris" > new_loc = [] > > for i in range(len(locations)): >new_loc.append(locations[i] + add_on) > > print new_loc > > Is this the most efficient way to do this? No. For a start you could use a

[Tutor] most efficient way to do this

2008-02-14 Thread Christopher Spears
I created a file called arrays.py: #!/usr/bin/python locations = ["/home/", "/office/" , "/basement/" , "/attic/"] Now I want to add the word "chris" on to each element of the locations list, so I wrote another script called chris_arrays.py: #!/usr/bin/python/ from arrays import locations add