Assignment to slices: Insert some : List Element Insert « List « Python






Assignment to slices: Insert some

Assignment to slices: Insert some

a = ['spam', 'eggs', 100, 1234]
# Insert some:
a[1:1] = ['bletch', 'xyzzy']
print a

a[:0] = a     # Insert (a copy of) itself at the beginning
print a

           
       








Related examples in the same category