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: > > #!/usr/bin/python/ > > from arrays import locations > > add_on = "chris" > new_loc = [] > > for i in range(len(locations)): > new_loc.append(locations[i] + add_on) > Alan gave the "best" answer.
FWIW I offer an intermediate improvement: for location in locations: new_loc.append(location + add_on) -- Bob Gailer 919-636-4239 Chapel Hill, NC _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor