Why not send the request?

 def wallpost(attach, post, token, cid):
 msg = "
 msg = post['response']['1']['text']
 data = {"attach": str ("attach"), "token": str(token), "cid": str(cid), "message": str(msg)}
 r = requests.post("https://api.vk.com/method/wall.post", data=data)
 return r.json()

Get the error

Traceback (most recent call last):
File "main.py", line 22, in wallpost
msg = post['response']['1']['text']
TypeError: list indices must be integers, not str

In the documentation for requests you can find the following code:
>>> payload = {'key1': 'value1', 'key2': 'value2'}

>>> r = requests.post("http://httpbin.org/post", data=payload)
>>> print(r.text)

Which, apparently, should work. Then why does not work my?
July 12th 19 at 16:39
1 answer
July 12th 19 at 16:41
Errors need to be able to read.
Written as:
TypeError: list indices must be integers, not str

This is a 5 string.
Most likely, post['response'] is a list, not a dictionary.

Find more questions by tags PythonWeb Development