Python 3.2.3rc2 (default, Mar 21 2012, 06:59:51) [GCC 4.6.3] on linux2 Type "copyright", "credits" or "license()" for more information. >>> x = [1, 7, 9] >>> x [1, 7, 9] >>> print(x) [1, 7, 9] >>> y = x >>> y [1, 7, 9] >>> x [1, 7, 9] >>> y[1] = 11 >>> y [1, 11, 9] >>> x [1, 11, 9] >>> z = [1, 7, 9] >>> z [1, 7, 9] >>> w = z[:] >>> z [1, 7, 9] >>> w[1] = 22 >>> w [1, 22, 9] >>> z [1, 7, 9] >>> v = [] >>> v [] >>> v[0] Traceback (most recent call last): File "", line 1, in v[0] IndexError: list index out of range >>> ================================ RESTART ================================ >>> . ---------------------------------------------------------------------- Ran 1 test in 0.021s OK >>> ================================ RESTART ================================ >>> .E ====================================================================== ERROR: test_add_two_to_first_two (__main__.TestJuly9) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/sukaeto/test1/july9_tests.py", line 10, in test_add_two_to_first_two self.assertEqual(add_two_to_first_two([1, 3, 5]), [3, 5, 5]) File "/home/sukaeto/test1/july9.py", line 16, in add_two_to_first_two new_num += [num +2] UnboundLocalError: local variable 'new_num' referenced before assignment ---------------------------------------------------------------------- Ran 2 tests in 0.030s FAILED (errors=1) >>> ================================ RESTART ================================ >>> .. ---------------------------------------------------------------------- Ran 2 tests in 0.028s OK >>> ================================ RESTART ================================ >>> .. ---------------------------------------------------------------------- Ran 2 tests in 0.033s OK >>> ================================ RESTART ================================ >>> Traceback (most recent call last): File "/home/sukaeto/test1/july9_tests.py", line 1, in from july9 import * File "/home/sukaeto/test1/july9.py", line 18 new_nums = [:] ^ SyntaxError: invalid syntax >>> ================================ RESTART ================================ >>> .. ---------------------------------------------------------------------- Ran 2 tests in 0.030s OK >>> ================================ RESTART ================================ >>> .E ====================================================================== ERROR: test_add_two_to_first_two (__main__.TestJuly9) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/sukaeto/test1/july9_tests.py", line 11, in test_add_two_to_first_two self.assertEqual(add_two_to_first_two([]), []) File "/home/sukaeto/test1/july9.py", line 19, in add_two_to_first_two new_nums[0] += 2 IndexError: list index out of range ---------------------------------------------------------------------- Ran 2 tests in 0.030s FAILED (errors=1) >>> ================================ RESTART ================================ >>> .. ---------------------------------------------------------------------- Ran 2 tests in 0.035s OK >>> [1, 2, 3] - [2, 3] Traceback (most recent call last): File "", line 1, in [1, 2, 3] - [2, 3] TypeError: unsupported operand type(s) for -: 'list' and 'list' >>> 2 * [2, 4, 5] [2, 4, 5, 2, 4, 5] >>> 3 * [2, 4, 5] [2, 4, 5, 2, 4, 5, 2, 4, 5] >>> 0 * [2, 4, 5] [] >>> x = 'stuff' >>> x[2] = 'i' Traceback (most recent call last): File "", line 1, in x[2] = 'i' TypeError: 'str' object does not support item assignment >>> type(x[2]) >>> x[2] 'u' >>> x[:4] 'stuf' >>> x[:-1] 'stuf' >>> y = [1, 2, 4, 5] >>> y = y[:2] + [3] + y[2:] >>> y [1, 2, 3, 4, 5] >>> y.insert(2, 7) >>> y [1, 2, 7, 3, 4, 5] >>> ================================ RESTART ================================ >>> ... ---------------------------------------------------------------------- Ran 3 tests in 0.043s OK >>> ================================ RESTART ================================ >>> .... ---------------------------------------------------------------------- Ran 4 tests in 0.055s OK >>>