SyntaxFix
Write A Post
Hire A Developer
Questions
The shortest I got: b = a[:2] + [3] + a[2:]
b = a[:2] + [3] + a[2:]
>>> >>> a = [1, 2, 4] >>> print a [1, 2, 4] >>> b = a[:2] + [3] + a[2:] >>> print a [1, 2, 4] >>> print b [1, 2, 3, 4]