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('abrakadabra')
>>> xs
0: ['a', 'b', 'r', 'a', 'k', 'a', 'd', 'a', 'b', 'r', 'a']
>>> for x in xs:
... print(x)
... xs.remove('a')
a
r
k
d
b
r
Traceback (most recent call last):
File "<pyshell#2>", line 3, in <module>
xs.remove('a')
~~~~~~~~~^^^^^
ValueError: list.remove(x): x not in list
>>> xs = list('abrakadabra')
... for i in len(xs):
... print(xs[i])
... xs.remove('a')
Traceback (most recent call last):
File "<pyshell#3>", line 2, in <module>
for i in len(xs):
~~~^^^^
TypeError: 'int' object is not iterable
>>> xs = list('abrakadabra')
... for i in range(len(xs)):
... print(xs[i])
... xs.remove('a')
a
r
k
d
b
r
Traceback (most recent call last):
File "<pyshell#4>", line 4, in <module>
xs.remove('a')
~~~~~~~~~^^^^^
ValueError: list.remove(x): x not in list
>>> xs = list('abrakadabra')
... for i,x in enumerate(xs):
... print(x)
... try:
... xs.remove('a')
... except:
... break
a
r
k
d
b
r
>>> xs = list('abrakadabra')
... for i,x in enumerate(xs):
... print(i, x)
... try:
... xs.remove('a')
... except:
... break
0 a
1 r
2 k
3 d
4 b
5 r
>>> zip(range(11), list('abrakadabra'))
1: <zip object at 0x00000200543BFC40>
>>> list(zip(range(11), list('abrakadabra')))
2: [(0, 'a'),
(1, 'b'),
(2, 'r'),
(3, 'a'),
(4, 'k'),
(5, 'a'),
(6, 'd'),
(7, 'a'),
(8, 'b'),
(9, 'r'),
(10, 'a')]
>>> xs = 'ahoj'
>>> for x in xs:
... print(x)
a
h
o
j
>>> xb = b'ahoj'
>>> for x in xb:
... print(x)
97
104
111
106
>>> def fn():
... pass
>>> fn
3: <function fn at 0x000002005441C180>
>>> fn()
>>> print(fn())
None
>>> fn(1)
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
fn(1)
~~^^^
TypeError: fn() takes 0 positional arguments but 1 was given
>>> def fn(x):
... pass
>>> fn(1)
>>> fn()
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
fn()
~~^^
TypeError: fn() missing 1 required positional argument: 'x'
>>> fn(1, 2)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
fn(1, 2)
~~^^^^^^
TypeError: fn() takes 1 positional argument but 2 were given
>>> def fn(x=10):
... print(x)
>>> fn()
10
>>> fn(1)
1
>>> fn(x=1)
1
>>> fn(x=2)
2
>>> def fn(x):
... print(x)
>>> fn(1)
1
>>> fn(x=1)
1
>>> fn(y=1)
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
fn(y=1)
~~^^^^^
TypeError: fn() got an unexpected keyword argument 'y'
>>> def fn(x, y, z, t=10, u='abc', v=[1, 2, 3]):
... print(x, y, z)
... print(t, u, v)
>>> fn()
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
fn()
~~^^
TypeError: fn() missing 3 required positional arguments: 'x', 'y', and 'z'
>>> fn(1, 2, 3)
1 2 3
10 abc [1, 2, 3]
>>> fn(1, 2, 3, 4, 5, 6)
1 2 3
4 5 6
>>> fn(1, 2, 3, 4, 5, v=6)
1 2 3
4 5 6
>>> fn(1, 2, 3, t=4, u=5, v=6)
1 2 3
4 5 6
>>>
>>> def fn(x, y, z, t=10, *, u='abc', v=[1, 2, 3]):
... print(x, y, z)
... print(t, u, v)
>>> fn(1, 2, 3)
1 2 3
10 abc [1, 2, 3]
>>> fn(1, 2, 3, 4)
1 2 3
4 abc [1, 2, 3]
>>> fn(1, 2, 3, 4, 5)
Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
fn(1, 2, 3, 4, 5)
~~^^^^^^^^^^^^^^^
TypeError: fn() takes from 3 to 4 positional arguments but 5 were given
>>> fn(1, 2, 3, 4, u=5)
1 2 3
4 5 [1, 2, 3]
>>> fn(1, 2, 3, 4, v=5)
1 2 3
4 abc 5
>>> fn(1, 2, z=3)
1 2 3
10 abc [1, 2, 3]
>>> def fn(x, /, y, z, t=10, *, u='abc', v=[1, 2, 3]):
... print(x, y, z)
... print(t, u, v)
>>> fn(1, 2, z=3)
1 2 3
10 abc [1, 2, 3]
>>> fn(1, y=2, z=3)
1 2 3
10 abc [1, 2, 3]
>>> fn(x=1, y=2, z=3)
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
fn(x=1, y=2, z=3)
~~^^^^^^^^^^^^^^^
TypeError: fn() got some positional-only arguments passed as keyword arguments: 'x'
>>> def fn():
... return 1, 2, 3, 'abc', []
>>> fn()
4: (1, 2, 3, 'abc', [])
>>> a, b, c, d, e = fn()
>>> _, _, c, _, _ = fn()
>>> c
5: 3
>>> def fn(*args, **kwargs):
... print(args)
... print(kwargs)
>>> fn()
()
{}
>>> fn(1, 2, 3)
(1, 2, 3)
{}
>>> fn(1, 2, 3, baf=333)
(1, 2, 3)
{'baf': 333}
>>> fn(1, 2, 3, baf=333, haf=666)
(1, 2, 3)
{'baf': 333, 'haf': 666}
>>> def fn(*x, **y):
... print(x)
... print(y)
>>> fn(1, 2, 3, baf=333, haf=666)
(1, 2, 3)
{'baf': 333, 'haf': 666}
>>> x = [3]
...
... def f(y):
... y[0] = 2 * y
>>> x
6: [3]
>>> f(x)
>>> x
7: [[3, 3]]
>>> def f(x, xs=[]):
... xs.append(x)
... return xs
>>> f(1, [1, 2, 3])
8: [1, 2, 3, 1]
>>> f('a', [1, 2, 3])
9: [1, 2, 3, 'a']
>>> f('a', [])
10: ['a']
>>> f('a', [])
11: ['a']
>>> f('a')
12: ['a']
>>> f('a')
13: ['a', 'a']
>>> f(333)
14: ['a', 'a', 333]
>>> f('a', [])
15: ['a']
>>> f(333)
16: ['a', 'a', 333, 333]
>>> 'ahoj' and 333
17: 333
>>> 'ahoj' or 333
18: 'ahoj'
>>> 0 or 333
19: 333
>>> [] or 333
20: 333
>>> False or 333
21: 333
>>> [] and 333
22: []
>>> from functools import cache
>>> @cache
... def fn(x, y):
... return x + y
>>>