Search code examples
pythonpython-telegram-botpyrogram

TypeError: 'coroutine' object is not subscriptable | Python3


▶️ Code :

photos = client.get_profile_photos("me")

await client.delete_profile_photos([p.file_id for p in photos[1:]])

▶️ Output / TraceBack :

Traceback (most recent call last):
  File "/plugins/code_runner.py", line 44, in eval
    await aexec(cmd, client, message)
  File "/plugins/code_runner.py", line 71, in aexec
    return await locals()["__aexec"](client, message)
  File "<string>", line 4, in __aexec
TypeError: 'coroutine' object is not subscriptable

I've tried many times, for examples:

(await client.delete_profile_photos([p.file_id for p in photos[1:]]))

await client.delete_profile_photos([async p.file_id for p in photos[2:]])

and many more,

but i can't figure it out, i'm noob so i hope someone can help me with this..


Solution

  • You haven't awaited the first call, get_profile_photos. So it's the coroutine, not the result.