se) MAC:Tue Sep 08:08:34:~> 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 = [2,3,4,5,True,"cat"] File "", line 1 x = [2,3,4,5,True,"cat"] ^ IndentationError: unexpected indent >>> x = [2,3,4,5,True,"cat"] >>> x[0] 2 >>> x[-1] 'cat' >>> x[-2] True >>> x = x[:-1] >>> x [2, 3, 4, 5, True] >>> x[1:3 ... ] [3, 4] >>> x[1:3] = ["A", "B", "C"] >>> x [2, 'A', 'B', 'C', 5, True] >>> x[1:1] = "dawg" >>> x [2, 'd', 'a', 'w', 'g', 'A', 'B', 'C', 5, 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] = 9,8,7,6,5 >>> x [9, 'd', 8, 'w', 7, 'A', 6, 'C', 5, True] >>> x = 0 >>> y = 1 >>> ## swap x and y? ... >>> tmp = x >>> x = y >>> y = tmp >>> x 1 >>> y 0 >>> x,y = y,x >>> x 0 >>> y 1 >>> x = ["Ethan", "Messier", "is", "nuts"] >>> x[0], x[1] = x[1], x[0] >>> x ['Messier', 'Ethan', 'is', 'nuts'] >>> one, two, three, four = x >>> one 'Messier' >>> two 'Ethan' >>> three 'is' >>> four 'nuts' >>> one, two, three, four, five = x Traceback (most recent call last): File "", line 1, in ValueError: not enough values to unpack (expected 5, got 4) >>> type(x) >>> ## tuple: immutible list ... >>> t = (1,2,3,4,5) >>> type(t) >>> t[0] 1 >>> t[1:3] (2, 3) >>> (1,2,3) + (4,5,6) (1, 2, 3, 4, 5, 6) >>> t[0] = "hippopotamus" Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> s = (1,2,3) >>> t = (4,5,6) >>> s + t (1, 2, 3, 4, 5, 6) >>> u = s >>> u is s True >>> s += t >>> s (1, 2, 3, 4, 5, 6) >>> u is s False >>> s = [1,2,3] >>> t = [4,5,6] >>> u = s >>> s += t >>> u is s True >>> # state for any sequeence: items present + order of items ... >>> x = 2 >>> y = 3 >>> x < 5 or y > 3 True >>> x < 5 and y > 3 False >>> True or False True >>> not True False >>>