Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> xs = [] >>> len(xs) 0: 0 >>> xs = [1, 2, 'a', 3, 'bc'] >>> len(xs) 1: 5 >>> xs[0] 2: 1 >>> xs[-1] 3: 'bc' >>> xs[3:] 4: [3, 'bc'] >>> xs[::-1] 5: ['bc', 3, 'a', 2, 1] >>> xs[::2] 6: [1, 'a', 'bc'] >>> dir(xs) 7: ['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> sort(xs) Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> sort(xs) ^^^^ NameError: name 'sort' is not defined >>> xs.sort() Traceback (most recent call last): File "<pyshell#11>", line 1, in <module> xs.sort() ~~~~~~~^^ TypeError: '<' not supported between instances of 'str' and 'int' >>> xs 8: [1, 2, 'a', 3, 'bc'] >>> xs.reverse() >>> xs 9: ['bc', 3, 'a', 2, 1] >>> for x in xs: ... print(x) bc 3 a 2 1 >>> for x in enumerate(xs): ... print(x) (0, 'bc') (1, 3) (2, 'a') (3, 2) (4, 1) >>> for x in enumerate(xs, start=10): ... print(x) (10, 'bc') (11, 3) (12, 'a') (13, 2) (14, 1) >>> for x in reversed(xs): ... print(x) 1 2 a 3 bc >>> xs 10: ['bc', 3, 'a', 2, 1] >>> xs.reverse() >>> xs 11: [1, 2, 'a', 3, 'bc'] >>> for x in reversed(xs): ... print(x) bc 3 a 2 1 >>> for x in xs: ... print(x) 1 2 a 3 bc >>> xs 12: [1, 2, 'a', 3, 'bc'] >>> xs[0] 13: 1 >>> xs[0] = 'ABC' >>> xs 14: ['ABC', 2, 'a', 3, 'bc'] >>> xs[0] 15: 'ABC' >>> xs[3:] 16: [3, 'bc'] >>> xs[5:] 17: [] >>> xs[3:] 18: [3, 'bc'] >>> xs[3:] = [666] >>> xs 19: ['ABC', 2, 'a', 666] >>> xs[3:] 20: [666] >>> xs[3:] = ['abc', 'def'] >>> xs 21: ['ABC', 2, 'a', 'abc', 'def'] >>> xs.append(666) >>> xs 22: ['ABC', 2, 'a', 'abc', 'def', 666] >>> xs.append([1, 2, 3]) >>> xs 23: ['ABC', 2, 'a', 'abc', 'def', 666, [1, 2, 3]] >>> xs[-1] 24: [1, 2, 3] >>> xs.extend([1, 2, 3]) >>> xs 25: ['ABC', 2, 'a', 'abc', 'def', 666, [1, 2, 3], 1, 2, 3] >>> xs += ['a', 'b', 'c'] >>> xs 26: ['ABC', 2, 'a', 'abc', 'def', 666, [1, 2, 3], 1, 2, 3, 'a', 'b', 'c'] >>> xs = xs + ['a', 'b', 'c'] >>> xs 27: ['ABC', 2, 'a', 'abc', 'def', 666, [1, 2, 3], 1, 2, 3, 'a', 'b', 'c', 'a', 'b', 'c'] >>> xs 28: ['ABC', 2, 'a', 'abc', 'def', 666, [1, 2, 3], 1, 2, 3, 'a', 'b', 'c', 'a', 'b', 'c'] >>> xs = [1, 2, 'a', 3, 'bc'] >>> xs 29: [1, 2, 'a', 3, 'bc'] >>> xs.insert(0, 'ABC') >>> xs 30: ['ABC', 1, 2, 'a', 3, 'bc'] >>> xs.insert(0, ['A', 'B', 'C']) >>> xs 31: [['A', 'B', 'C'], 'ABC', 1, 2, 'a', 3, 'bc'] >>> xs[0] 32: ['A', 'B', 'C'] >>> len(xs) 33: 7 >>> xs.insert(-1, 'ABC') >>> xs 34: [['A', 'B', 'C'], 'ABC', 1, 2, 'a', 3, 'ABC', 'bc'] >>> len(xs) 35: 8 >>> xs.insert(8, 'ABC') >>> xs 36: [['A', 'B', 'C'], 'ABC', 1, 2, 'a', 3, 'ABC', 'bc', 'ABC'] >>> xs 37: [['A', 'B', 'C'], 'ABC', 1, 2, 'a', 3, 'ABC', 'bc', 'ABC'] >>> del xs >>> xs Traceback (most recent call last): File "<pyshell#64>", line 1, in <module> xs NameError: name 'xs' is not defined >>> xs = [1, 2, 'a', 3, 'bc'] >>> xs 38: [1, 2, 'a', 3, 'bc'] >>> xs[0] 39: 1 >>> xs 40: [1, 2, 'a', 3, 'bc'] >>> del xs[0] >>> xs 41: [2, 'a', 3, 'bc'] >>> xs[2:] 42: [3, 'bc'] >>> xs[::2] 43: [2, 3] >>> del xs[::2] >>> xs 44: ['a', 'bc'] >>> xs = [1, 2, 'a', 3, 'bc'] >>> xs 45: [1, 2, 'a', 3, 'bc'] >>> xs.pop() 46: 'bc' >>> xs 47: [1, 2, 'a', 3] >>> xs.pop() 48: 3 >>> xs 49: [1, 2, 'a'] >>> xs.pop(0) 50: 1 >>> xs 51: [2, 'a'] >>> xs.pop(-1) 52: 'a' >>> xs 53: [2] >>> xs = [1, 2, 'a', 3, 'bc'] >>> xs 54: [1, 2, 'a', 3, 'bc'] >>> xs.remove('bc') >>> xs 55: [1, 2, 'a', 3] >>> xs.extend(['bc', 333, 'bc']) >>> xs 56: [1, 2, 'a', 3, 'bc', 333, 'bc'] >>> xs.remove('bc') >>> xs 57: [1, 2, 'a', 3, 333, 'bc'] >>> xs = [1, 2, 'a', 3, 'bc'] >>> xs.extend(['bc', 333, 'bc']) >>> xs 58: [1, 2, 'a', 3, 'bc', 'bc', 333, 'bc'] >>> [x for x in xs if x != 'bc'] 59: [1, 2, 'a', 3, 333] >>> (x for x in xs if x != 'bc') 60: <generator object <genexpr> at 0x000001AF69729FF0> >>> ys = [x for x in xs if x != 'bc'] >>> ys 61: [1, 2, 'a', 3, 333] >>> xs 62: [1, 2, 'a', 3, 'bc', 'bc', 333, 'bc'] >>> zs = [] ... for x in xs: ... if x != 'bc': ... zs.append(x) >>> zs 63: [1, 2, 'a', 3, 333] >>> [(x, y) for x in [1, 2, 3] for y in 'abc'] 64: [(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c'), (3, 'a'), (3, 'b'), (3, 'c')] >>> [(x, y) for x in (1, 2, 3) for y in 'abc'] 65: [(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c'), (3, 'a'), (3, 'b'), (3, 'c')] >>> [(x, y) for x in {1, 2, 3} for y in 'abc'] 66: [(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c'), (3, 'a'), (3, 'b'), (3, 'c')] >>> ds = { 'a': 'ahoj', 123: 'svět', (12, 'fokus'): 666, } >>> ds 67: {123: 'svět', 'a': 'ahoj', (12, 'fokus'): 666} >>> len(ds) 68: 3 >>> ds[123] 69: 'svět' >>> ds['a'] 70: 'ahoj' >>> ds[(12, 'fokus')] 71: 666 >>> ds[12, 'fokus'] 72: 666 >>> ds[1] Traceback (most recent call last): File "<pyshell#113>", line 1, in <module> ds[1] ~~^^^ KeyError: 1 >>> ds.get(1) >>> ds.get(123) 73: 'svět' >>> print(ds.get(1)) None >>> ds.get(123, 'ABC') 74: 'svět' >>> ds.get(1, 'ABC') 75: 'ABC' >>>