Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> Please enter your name (or 0 to stop): Alice Birthdate: 2/3/1980 Favorite color: yellow record: Alice 2/3/1980 yellow Please enter your name (or 0 to stop): Bob Birthdate: 2/22/1981 Favorite color: blue record: Bob 2/22/1981 blue Please enter your name (or 0 to stop): 0 output: ['Alice\t2/3/1980\tyellow', 'Bob\t2/22/1981\tblue'] >>> ================================ RESTART ================================ >>> Please enter your name (or 0 to stop): Alice Birthdate: 2/3/1980 Favorite color: yellow record: Alice 2/3/1980 yellow Please enter your name (or 0 to stop): Bob Birthdate: 2/22/1981 Favorite color: blue record: Bob 2/22/1981 blue Please enter your name (or 0 to stop): 0 output: ['Alice\t2/3/1980\tyellow\n', 'Bob\t2/22/1981\tblue\n'] >>> ================================ RESTART ================================ >>> Please enter your name (or 0 to stop): Alice Birthdate: 2/3/1980 Favorite color: yellow Traceback (most recent call last): File "C:/Users/mil28/Desktop/writing_example3.py", line 10, in record = '\t'.join(record) TypeError: sequence item 2: expected str instance, int found >>> record = ('Alice', '2/3/1980', 'yellow\n') >>> record = ('Alice', '2/3/1980', 24, 'yellow\n') >>> [str(a) for a in record if not isinstance(a, str)] ['24'] >>> str('cat') 'cat' >>> ================================ RESTART ================================ >>> Please enter your name (or 0 to stop): Alice Birthdate: 2/3/1980 Favorite color: yellow record: Alice 2/3/1980 24 yellow Please enter your name (or 0 to stop): Bob Birthdate: 2/22/1981 Favorite color: blue record: Bob 2/22/1981 24 blue Please enter your name (or 0 to stop): 0 output: ['Alice\t2/3/1980\t24\tyellow\n', 'Bob\t2/22/1981\t24\tblue\n'] >>> ================================ RESTART ================================ >>> ['Alice\t2/3/1980\t24\tyellow\n', 'Bob\t2/22/1981\t24\tblue\n'] >>> ================================ RESTART ================================ >>> ['Alice\t2/3/1980\t24\tyellow\n', 'Bob\t2/22/1981\t24\tblue\n'] >>> ================================ RESTART ================================ >>> ['Alice', '2/3/1980', '24', 'yellow'] ['Bob', '2/22/1981', '24', 'blue'] >>> ================================ RESTART ================================ >>> 1: ['Alice\t2/3/1980\t24\tyellow\n', 'Bob\t2/22/1981\t24\tblue\n'] 2: [] >>> ================================ RESTART ================================ >>> ['Alice', '2/3/1980', '24', 'yellow'] ['Bob', '2/22/1981', '24', 'blue'] >>> ================================ RESTART ================================ >>> ['Alice', '2/3/1980', '24', 'yellow'] ['Bob', '2/22/1981', '24', 'blue'] >>> ================================ RESTART ================================ >>> ['Alice', '2/3/1980', 24, 'yellow'] ['Bob', '2/22/1981', 24, 'blue'] >>> a = [1, 2, 3, 4, 5, 6, 7] >>> a[5:10] [6, 7] >>> del a[5:10] >>> a [1, 2, 3, 4, 5] >>> sum(a) 15 >>> b = [1, 2, 3, 'a', 'b', 'c'] >>> sum(b) Traceback (most recent call last): File "", line 1, in sum(b) TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> c = [1, 2, 3, 1.5, 2.5, 3.0] >>> sum(c) 13.0 >>> d = "My cat is black." >>> d.split() ['My', 'cat', 'is', 'black.'] >>> e = d.split() >>> e ['My', 'cat', 'is', 'black.'] >>> ' '.join(e) 'My cat is black.' >>> e.join(' ') Traceback (most recent call last): File "", line 1, in e.join(' ') AttributeError: 'list' object has no attribute 'join' >>> ' and '.join(e) 'My and cat and is and black.' >>> c [1, 2, 3, 1.5, 2.5, 3.0] >>> b [1, 2, 3, 'a', 'b', 'c'] >>> ' '.join(b) Traceback (most recent call last): File "", line 1, in ' '.join(b) TypeError: sequence item 0: expected str instance, int found >>> ' '.join([str(v) for v in b]) '1 2 3 a b c' >>> if letter in ('a', 'e', 'i', 'o', 'u') KeyboardInterrupt >>> b [1, 2, 3, 'a', 'b', 'c'] >>> z = b[3:10] >>> z ['a', 'b', 'c'] >>> b[3:] ['a', 'b', 'c'] >>> b[3:len(b)] ['a', 'b', 'c'] >>> b[3::2] ['a', 'c'] >>> b[3:6] ['a', 'b', 'c'] >>> b [1, 2, 3, 'a', 'b', 'c'] >>> b[3:5] ['a', 'b'] >>> b[3:len(b)] ['a', 'b', 'c'] >>> b[3:-1] ['a', 'b'] >>> b[len(b)-1] 'c' >>> b[-1] 'c' >>> len(b) 6 >>> b[5] 'c' >>> b[-3:] ['a', 'b', 'c'] >>> b [1, 2, 3, 'a', 'b', 'c'] >>> b[0:3] [1, 2, 3] >>> b[:3] [1, 2, 3] >>> b[1:5:2] [2, 'a'] >>> b[1:6:2] [2, 'a', 'c'] >>> b [1, 2, 3, 'a', 'b', 'c'] >>> b[0:2:5] [1] >>>