changing list items

2006-11-22 Thread eight02645999
hi say i have a list alist = ['a','b','c','e','d','f'] I wanted to change the elements , say alist[2:4] . If i do alist[2:4] = t , it gives ['a', 'b', 't', 'd', 'f'] which is not what i want. I wanted alist = ['a','b','t','t','d','f'] My list may have more elements, and i may need to replace

Re: changing list items

2006-11-22 Thread bearophileHUGS
A possibile first solution: alist = ['a','b','c','e','d','f'] inf, sup = 2, 4 alist[inf:sup] = [t] * (sup - inf) alist ['a', 'b', 't', 't', 'd', 'f'] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list