(base) MAC:Wed Sep 09:14:16:Downloads> python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = [5,3,-2, True, "caterwaul"] >>> x[1] 3 >>> x[-1] 'caterwaul' >>> x[-2] True >>> x = x[:-1] >>> x [5, 3, -2, True] >>> x[1:3] [3, -2] >>> x[1:3] = ["cat", "dawg", "tapir"] >>> >>> x [5, 'cat', 'dawg', 'tapir', True] >>> x[3:3] = "mess" >>> x [5, 'cat', 'dawg', 'm', 'e', 's', 's', 'tapir', True] >>> x[::2] [5, 'dawg', 'e', 's', True] >>> x[::2] = [] Traceback (most recent call last): File "", line 1, in ValueError: attempt to assign sequence of size 0 to extended slice of size 5 >>> x[::2] = [10,11,12,13,14] >>> x [10, 'cat', 11, 'm', 12, 's', 13, 'tapir', 14] >>> x = 0 >>> y = 1 >>> tmp = x >>> x = y >>> y= tmp >>> x 1 >>> y 0 >>> x,y = y,x >>> x 0 >>> y 1 >>> x = ["Fawcett", " File "", line 1 x = ["Fawcett", " ^ SyntaxError: EOL while scanning string literal >>> x = ["Fawcett", "is", "spacing", "out] File "", line 1 x = ["Fawcett", "is", "spacing", "out] ^ SyntaxError: EOL while scanning string literal >>> x = ["Fawcett", "is", "spacing", "out"] >>> x[0],x[1] = x[1],x[0] >>> x ['is', 'Fawcett', 'spacing', 'out'] >>> alpha, beta, gamma, delta = x >>> alpha 'is' >>> beta 'Fawcett' >>> gamma 'spacing' >>> delta 'out' >>> type(x) >>> hash(5) 5 >>> hash("foo") 7849859638514754987 >>> hash([]) Traceback (most recent call last): File "", line 1, in TypeError: unhashable type: 'list' >>> #tuple ... >>> x = (1,2,3,4,5) >>> x[0] 1 >>> #indexing is the same ... >>> x[3:5] (4, 5) >>> x[0] = "pegasus" Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> [1,2,3] + [4,5,6] [1, 2, 3, 4, 5, 6] >>> (1,2,3) + (4,5,6) (1, 2, 3, 4, 5, 6) >>> (base) MAC:Wed Sep 09:14:33:Downloads> !p python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> s = [1,2,3] >>> t = [4,5,6] >>> u = s >>> s += t >>> s [1, 2, 3, 4, 5, 6] >>> u is s True >>> s = (1,2,3) >>> t = (4,5,6) >>> u = s >>> s += t >>> s (1, 2, 3, 4, 5, 6) >>> u is s False >>> u (1, 2, 3) >>> (base) MAC:Wed Sep 09:14:59:Downloads>