Как решить, помогите! TypeError: 'builtin_function_or_method' object is not subscriptable

Рейтинг: -2Ответов: 1Опубликовано: 23.07.2023
        all_hitbox_zombie_in_game.append(hitbox_zombie1 and hitbox_zombie2 and hitbox_zombie3 and hitbox_zombie4 and hitbox_zombie5 and
                                         hitbox_zombie6 and hitbox_zombie7 and hitbox_zombie8 and hitbox_zombie9 and hitbox_zombie10 and
                                         hitbox_zombie11 and hitbox_zombie12 and hitbox_zombie13 and hitbox_zombie14 and hitbox_zombie15 and
                                         hitbox_zombie16 and hitbox_zombie17 and hitbox_zombie18 and hitbox_zombie19 and hitbox_zombie20 and
                                         hitbox_zombie21 and hitbox_zombie22 and hitbox_zombie23 and hitbox_zombie24 and hitbox_zombie25 and
                                         hitbox_zombie26)
    


        if hitbox_player.colliderect[all_hitbox_zombie_in_game]:
            stop_game = False

Ответы

▲ 1
if hitbox_player.colliderect[all_hitbox_zombie_in_game]:

colliderect - это метод (функция внутри класса), о чём вам толсто намекает текст ошибки. Метод (функцию) нужно вызывать с помощью круглых скобок, а вы пытаетесь обратиться к нему по индексу, используя квадратные скобки, о чём также написано в тексте ошибки. Итого, эта ошибка скорее всего лечится так:

if hitbox_player.colliderect(all_hitbox_zombie_in_game):
                            ^------- тут и тут -------^