I
I
idk583342022-02-07 00:03:35
Python
idk58334, 2022-02-07 00:03:35

TypeError: list indices must be integers or slices, not str, what's the problem?

mistake
TypeError: list indices must be integers or slices, not str
when trying to display a list of group admins (print(admins["contacts"]))

import vk_api

session = vk_api.VkApi(token=тут был токен')
vk = session.get_api()

GROUP = '198174344'
USERID = '198174344'

status= session.method('status.get', {'group_id': USERID})
print(status['text'])


admins = session.method('groups.getById', {'group_id': GROUP,'fields': 'contacts'})
print('')


print(admins["contacts"])

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2022-02-07
@idk58334

admins is a list, not a dictionary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question