Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> xs = list('Ahoj, světe!') >>> xs 0: ['A', 'h', 'o', 'j', ',', ' ', 's', 'v', 'ě', 't', 'e', '!'] >>> dir(xs) 1: ['__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'] >>> it = iter(xs) >>> type(it) 2: <class 'list_iterator'> >>> dir(it) 3: ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__length_hint__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__'] >>> next(it) 4: 'A' >>> next(it) 5: 'h' >>> next(it) 6: 'o' >>> next(it) 7: 'j' >>> next(it) 8: ',' >>> next(it) 9: ' ' >>> next(it) 10: 's' >>> next(it) 11: 'v' >>> next(it) 12: 'ě' >>> next(it) 13: 't' >>> next(it) 14: 'e' >>> next(it) 15: '!' >>> next(it) Traceback (most recent call last): File "<pyshell#18>", line 1, in <module> next(it) ~~~~^^^^ StopIteration >>> it = iter(xs) >>> next(it) 16: 'A' >>> next(it) 17: 'h' >>> next(it) 18: 'o' >>> next(it) 19: 'j' >>> next(it) 20: ',' >>> for i in it: ... print(i) s v ě t e ! >>> xs 21: ['A', 'h', 'o', 'j', ',', ' ', 's', 'v', 'ě', 't', 'e', '!'] >>> ys = [] ... for x in xs: ... ys.append(1) >>> ys 22: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] >>> zs = [1 for x in xs] >>> zs 23: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] >>> us = 'pořadí;název;rok;režisér' >>> us.split(';') 24: ['pořadí', 'název', 'rok', 'režisér'] >>> us.split(';', max=1) Traceback (most recent call last): File "<pyshell#33>", line 1, in <module> us.split(';', max=1) ~~~~~~~~^^^^^^^^^^^^ TypeError: split() got an unexpected keyword argument 'max' >>> us.split(';', maxsplit=1) 25: ['pořadí', 'název;rok;režisér'] >>> us.split(';', 1) 26: ['pořadí', 'název;rok;režisér'] >>> xs 27: ['A', 'h', 'o', 'j', ',', ' ', 's', 'v', 'ě', 't', 'e', '!'] >>> for x in xs: ... print(x, end=' ') A h o j , s v ě t e ! >>> for x in sorted(xs): ... print(x, end=' ') ! , A e h j o s t v ě >>> names = ["John", "Wendy", "Pete", "Jane", "David", "Amanda", "Ix"] >>> type(names) 28: <class 'list'> >>> dir(names) 29: ['__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'] [About 47 more lines. Double-click to unfold] >>> sorted(names) 30: ['Amanda', 'David', 'Ix', 'Jane', 'John', 'Pete', 'Wendy'] >>> def fn(x): ... print(x) ... return x ... ... sorted(names, key=fn) John Wendy Pete Jane David Amanda Ix 31: ['Amanda', 'David', 'Ix', 'Jane', 'John', 'Pete', 'Wendy'] >>> def fn(x): ... print(x) ... return len(x) ... ... sorted(names, key=fn) John Wendy Pete Jane David Amanda Ix 32: ['Ix', 'John', 'Pete', 'Jane', 'Wendy', 'David', 'Amanda'] >>> names 33: ['John', 'Wendy', 'Pete', 'Jane', 'David', 'Amanda', 'Ix'] >>> def fn(x): ... print(x) ... return len(x), x ... ... sorted(names, key=fn) John Wendy Pete Jane David Amanda Ix 34: ['Ix', 'Jane', 'John', 'Pete', 'David', 'Wendy', 'Amanda'] >>> def fn(x): ... return len(x), x ... ... sorted(names, key=fn) 35: ['Ix', 'Jane', 'John', 'Pete', 'David', 'Wendy', 'Amanda'] >>> sorted(names, key=lambda x: (len(x), x)) 36: ['Ix', 'Jane', 'John', 'Pete', 'David', 'Wendy', 'Amanda'] >>> '''sorted(names, key=lambda x: len(x), x)''' 37: 'sorted(names, key=lambda x: len(x), x)' >>> import locale >>> dir(locale) 38: ['CHAR_MAX', 'Error', 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_append_modifier', '_build_localename', '_builtin_str', '_collections_abc', '_format', '_getdefaultlocale', '_group', '_grouping_intervals', '_localeconv', '_localize', '_override_localeconv', '_parse_localename', '_percent_re', '_print_locale', '_replace_encoding', '_setlocale', '_strcoll', '_strip_padding', '_strxfrm', '_test', 'atof', 'atoi', 'currency', 'delocalize', 'encodings', 'format_string', 'functools', 'getdefaultlocale', 'getencoding', 'getlocale', 'getpreferredencoding', 'locale_alias', 'locale_encoding_alias', 'localeconv', 'localize', 'normalize', 're', 'setlocale', 'str', 'strcoll', 'strxfrm', 'sys', 'windows_locale'] [About 59 more lines. Double-click to unfold] >>> locale.getlocale() 39: ('Czech_Czechia', '1250') >>> sorted('koníček', key=locale.strxfrm) 40: ['e', 'k', 'k', 'n', 'o', 'í', 'č'] >>> locale.setlocale(locale.LC_ALL, ('czech', 'UTF-8')) 41: 'cs_CZ.UTF-8' >>> sorted('koníček', key=locale.strxfrm) 42: ['č', 'e', 'í', 'k', 'k', 'n', 'o'] >>> sorted('koňníček', key=locale.strxfrm) 43: ['č', 'e', 'í', 'k', 'k', 'n', 'ň', 'o'] >>>