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. >>> a = ['ant', 'bird', 'cat', 'dog'] >>> a[0:len(a):3] ['ant', 'dog'] >>> a[0] 'ant' >>> b = ['bird'] >>> b ['bird'] >>> c = [] >>> c [] >>> len(c) 0 >>> a[0:len(a):4] ['ant'] >>> a ['ant', 'bird', 'cat', 'dog'] >>> len(a) 4 >>> a ['ant', 'bird', 'cat', 'dog'] >>> a.insert(1, 'elephant') >>> a ['ant', 'elephant', 'bird', 'cat', 'dog'] >>> a.append('mouse') >>> a ['ant', 'elephant', 'bird', 'cat', 'dog', 'mouse'] >>> a.extend([1, 2, 3]) >>> a ['ant', 'elephant', 'bird', 'cat', 'dog', 'mouse', 1, 2, 3] >>> a.extend(5) Traceback (most recent call last): File "", line 1, in a.extend(5) TypeError: 'int' object is not iterable >>> for v in a: print(v) ant elephant bird cat dog mouse 1 2 3 >>> for v in 5: print(v) Traceback (most recent call last): File "", line 1, in for v in 5: TypeError: 'int' object is not iterable >>> for v in 15.8: print(v) Traceback (most recent call last): File "", line 1, in for v in 15.8: TypeError: 'float' object is not iterable >>> a.extend('horse') >>> a ['ant', 'elephant', 'bird', 'cat', 'dog', 'mouse', 1, 2, 3, 'h', 'o', 'r', 's', 'e'] >>> for c in 'horse': print(c) h o r s e >>> for e in iterable: a.append(e) Traceback (most recent call last): File "", line 1, in for e in iterable: NameError: name 'iterable' is not defined >>> a.insert('horse') Traceback (most recent call last): File "", line 1, in a.insert('horse') TypeError: insert() takes exactly 2 arguments (1 given) >>> items = ['ant', 'bird', 'cat', 'dog'] >>> items[-2] 'cat' >>> items[2:] ['cat', 'dog'] >>> items[-2:] ['cat', 'dog'] >>> 'Newlines are represented with '\n' and show up as ' ', i.e. a break in the line.'.split() SyntaxError: unexpected character after line continuation character >>> "Newlines are represented with '\\n' and show up as '\n', i.e. a break in the line." "Newlines are represented with '\\n' and show up as '\n', i.e. a break in the line." >>> print("Newlines are represented with '\\n' and show up as '\n', i.e. a break in the line.") Newlines are represented with '\n' and show up as ' ', i.e. a break in the line. >>> "Newlines are represented with '\\n' and show up as '\n', i.e. a break in the line.".split() ['Newlines', 'are', 'represented', 'with', "'\\n'", 'and', 'show', 'up', 'as', "'", "',", 'i.e.', 'a', 'break', 'in', 'the', 'line.'] >>> 'ant bird\tcat\ndog'.split() ['ant', 'bird', 'cat', 'dog'] >>> 'Cats and dogs'.split('') Traceback (most recent call last): File "", line 1, in 'Cats and dogs'.split('') ValueError: empty separator >>> ''.join(['Cats', 'and', 'dogs'] ) 'Catsanddogs' >>> wishlist = ['ant', 'bird', 'cat', 'dog', 'pony'] >>> for e in wishlist: if e == 'pony': wishlist.remove() Traceback (most recent call last): File "", line 3, in wishlist.remove() TypeError: remove() takes exactly one argument (0 given) >>> wishlist ['ant', 'bird', 'cat', 'dog', 'pony'] >>> wishlist.remove('pony') >>> wishlist ['ant', 'bird', 'cat', 'dog'] >>> a = ['ant', 'bird'] >>> a = [] >>> b = list() >>> a [] >>> b [] >>> b = list('horse') >>> b ['h', 'o', 'r', 's', 'e'] >>> str(15) '15' >>> range(0, 10) range(0, 10) >>> list(range(0, 10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> t = tuple() >>> t () >>> a [] >>> b ['h', 'o', 'r', 's', 'e'] >>> tuple(b) ('h', 'o', 'r', 's', 'e') >>> a = (1, 2, 3) >>> a (1, 2, 3) >>> b = ('a', 'b', 'c') >>> a + b (1, 2, 3, 'a', 'b', 'c') >>> a.append(4) Traceback (most recent call last): File "", line 1, in a.append(4) AttributeError: 'tuple' object has no attribute 'append' >>> c = (2) >>> d = [2] >>> d [2] >>> c 2 >>> (2 + 5) / 2 3.5 >>> (7) / 2 3.5 >>> (2+5) 7 >>> range(10) range(0, 10) >>> (2, ) (2,) >>> (,) SyntaxError: invalid syntax >>> () () >>> tuple() () >>> (1, 2, 3, ) (1, 2, 3) >>> b = 1, 2, 3 >>> b (1, 2, 3) >>> b = 1, >>> b (1,) >>> b = SyntaxError: invalid syntax >>> b = 1, 2, 3 >>> b (1, 2, 3) >>> b[0] = 10 Traceback (most recent call last): File "", line 1, in b[0] = 10 TypeError: 'tuple' object does not support item assignment >>> b[0] 1 >>> b[::2] (1, 3) >>> c = list(b) >>> b (1, 2, 3) >>> c [1, 2, 3] >>> c[0] = 10 >>> c [10, 2, 3] >>> b (1, 2, 3) >>> b = tuple(c) >>> b (10, 2, 3) >>> ofile = open('asdf.txt', 'w') Traceback (most recent call last): File "", line 1, in ofile = open('asdf.txt', 'w') PermissionError: [Errno 13] Permission denied: 'asdf.txt' >>> import os >>> os.getcwd() 'C:\\Python34' >>> os.chdir('C:\Users\mil28\Desktop') KeyboardInterrupt >>> print('\t') >>> print('\ttext') text >>> os.chdir('C:\Users\mil28\Desktop') SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape >>> os.chdir('C:\\Users\\mil28\\Desktop') >>> os.getcwd() 'C:\\Users\\mil28\\Desktop' >>> ================================ RESTART ================================ >>> >>> print("This is some text.") This is some text. >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> This is some text. This is more text.Here is more text.Here is more text. >>> ================================ RESTART ================================ >>> This i >>> ================================ RESTART ================================ >>> This i s so >>> ================================ RESTART ================================ >>> This i s so me text. This is more text.Here is more text.Here is more text. >>> ================================ RESTART ================================ >>> This i s so me text. This is more text.Here is more text.Here is more text. >>> ================================ RESTART ================================ >>> This i s so me text. This is more text.Here is more text.Here is more text. This is some text. This is more text.Here is more text.Here is more text. This is some text. This is more text.Here is more text.Here is more text. >>>