Why bot does not respond to the message?

The bot receives the message, sees it but does not answer it.
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api

vk = vk_api.VkApi(token='my token')
vk._auth_token()
vk.get_api()

add = VkBotLongPoll(vk, id in my group)

while True:
 for event in add.listen():
 if event.type == VkBotEventType.MESSAGE_NEW:
 if event.object.peer_id == event.object.from_id:
 print('Message 1')
 if event.object.text.lower() == "Hello":
 print('Message 2')
 vk.messages.send(peer_id=event.object.peer_id, message='Hello!', random_id=0)

The terminal displays "1 Message received" and "Message 2" - no.
Probably a mistake in this piece, but how to solve it ?
if event.object.text.lower() == "Hello":
March 20th 20 at 11:51
1 answer
March 20th 20 at 11:53
Solution
Will be Wang, but most likely, the function lower() returns Helloand not hi.
So your condition is always false.

UPD:

Replace the string "Hello" string "Hello"

Well, learn to debug your code, it's a good skill.

Output the content value of the event.object.text.lower() before you do the last terms.
To see what value is in this variable.

print(event.object.text.lower())
Does not work - April_Harb commented on March 20th 20 at 11:56
Replace the string "Hello" string "Hello" - Eryn_Herz commented on March 20th 20 at 11:59
Well, learn to debug your code, it's a good skill.

Output the content value of the event.object.text.lower() before you do the last terms. To see what value is in this variable.

print(event.object.text.lower()) - Eryn_Herz commented on March 20th 20 at 12:02
@Natalia.Schumm90, Thanks a lot!
+rep - April_Harb commented on March 20th 20 at 12:05

Find more questions by tags PythonAPIVKontakteBots