Mega Code Archive

 
Categories / Python Tutorial / List
 

LHS slice and the RHS may each be of any length

x = [1, 2, 3, 4] x[1:3] = [22, 33, 44]     # x is now [1, 22, 33, 44, 4] print x x[1:4] = [8, 9]           # x is now [1, 8, 9, 4] print x