This works fine when using a CPython build with assertions disabled, and also works fine with Python 3.12 with assertions enabled. Since Python 3.13 (and still true on main), importing a ...
string = "abc" string[0] = "d" TypeError: 'str' object does not support item assignment num = 123 num[0] = 4 TypeError: 'int' object is not subscriptable my_string ...