Michael at dhcp-47-117 in ~/Dropbox/Projects/cs88/cs88/src on master [!] 👉 python2 Python 2.7.17 (default, Oct 24 2019, 12:57:38) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> >>> sentence = 'I am taking CS88' >>> senttence Traceback (most recent call last): File "", line 1, in NameError: name 'senttence' is not defined >>> sentence 'I am taking CS88' >>> sentence.split(' ') ['I', 'am', 'taking', 'CS88'] >>> lst = sentence.split(' ') >>> " ".join(lst) 'I am taking CS88' >>> len(sentence) 16 >>> len(lst) 4 >>> lsr Traceback (most recent call last): File "", line 1, in NameError: name 'lsr' is not defined >>> lst ['I', 'am', 'taking', 'CS88'] >>> lst + ['What', 'about', 'you?'] ['I', 'am', 'taking', 'CS88', 'What', 'about', 'you?'] >>> lst / ['What', 'about', 'you?'] Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for /: 'list' and 'list' >>> >>> >>> lst[0] 'I' >>> lst[4] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> lst[3] 'CS88' >>> lst[ .DS_Store disc/ roster/ .gitignore exam/ slides/ Makefile exclusionary_sol_sharing/ templates/ README.md howamidoing/ tutor/ __pycache__/ main/ web/ assets/ prob/ config.py proj/ >>> lst[ KeyboardInterrupt >>> >>> >>> lst[-1] 'CS88' >>> lst[ len(lst) - 1] 'CS88' >>> help(list) >>> S = "Hello, world!" >>> S 'Hello, world!' >>> L = [2,0,9,10,11] >>> [ L[1], L[2], L[3] ] [0, 9, 10] >>> L[1] 0 >>> L[1:4]] File "", line 1 L[1:4]] ^ SyntaxError: invalid syntax >>> L[1:4] [0, 9, 10] >>> S[1:4] 'ell' >>> len(L) 5 >>> L[4] 11 >>> L [2, 0, 9, 10, 11] >>> L[0:5] [2, 0, 9, 10, 11] >>> L[0:len(L)] [2, 0, 9, 10, 11] >>> S[0:5:2] 'Hlo' >>> S[0] + S[2] + S[4] 'Hlo' >>> S[0:5:-2] '' >>> S[0:5:-1] '' >>> S[5:0:-2] ',le' >>> S[4:-1:-2] '' >>> S 'Hello, world!' >>> S[::-1] '!dlrow ,olleH' >>> l Traceback (most recent call last): File "", line 1, in NameError: name 'l' is not defined >>> L [2, 0, 9, 10, 11] >>> L[::-1] [11, 10, 9, 0, 2] >>> L [2, 0, 9, 10, 11] >>> L.reverse() >>> L [11, 10, 9, 0, 2] >>> L [11, 10, 9, 0, 2] >>> L.reverse() >>> L [2, 0, 9, 10, 11] >>> >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> (env) Michael at dhcp-47-117 in ~/Dropbox/Projects/cs88/cs88/src on master [!] 👉 python3 Python 3.10.0 (default, Oct 13 2021, 06:45:00) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> range(10) range(0, 10) >>> range(1000000000000000000000000000000) range(0, 1000000000000000000000000000000) >>> list( range(0, 10) ) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list( range(0, 10, 2) ) [0, 2, 4, 6, 8] >>> range(0, 10, 2)[3] 6 >>> for number in range(10): ... print(number) ... 0 1 2 3 4 5 6 7 8 9 >>> for char in S: ... print(char) ... Traceback (most recent call last): File "", line 1, in NameError: name 'S' is not defined >>> S = 'Hello, world' >>> for char in S: ... print(char) ... H e l l o , w o r l d >>> courses = [ 'CS88', 'DATA8 File "", line 1 courses = [ 'CS88', 'DATA8 ^ SyntaxError: unterminated string literal (detected at line 1) >>> courses = [ 'CS88', 'DATA8', 'MATH54'] >>> for course in courses: ... print('I am taking ' + course) ... I am taking CS88 I am taking DATA8 I am taking MATH54 >>>