View Single Post
Old May 2nd, 2006, 3:37 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,868
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Also, it may be a good idea to become familiar with list indexing. Yes, Andro's code works perfectly for what you need to do. However, there will be times when you need to use an alternative method (for other purposes, eg. replacing the third element), list indexing...

my_list = ['a', 'b', 'c', 'd', 'e']
new_list = my_list[:3] + ['new'] + my_list[3:] 
# essentially: ['a', 'b', 'c'] + ['new'] + ['d', 'e']
print new_list

Any questions, feel free to ask.
Sane is offline   Reply With Quote