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:
>
> #!/
"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
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