[Tutor] list.append(x) but at a specific 'i'

Norman Khine norman at khine.net
Wed Sep 22 00:30:09 CEST 2010


hello, how do i extend a python list but from a given [i], for example:

>>> a = ['a', 'b', 'e']
>>> b = ['c', 'd']

>>> a + b
['a', 'b', 'e', 'c', 'd']
>>>

but i want to put the items of 'b' at [-2] for example.

thanks

-- 
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )


More information about the Tutor mailing list