W
W
WolfInChains2020-05-16 16:48:49
Python
WolfInChains, 2020-05-16 16:48:49

Why does the script only work with 1 name?

When adding 1 more name to the name line, the script stops working, why?

text_4 = event.obj['text'].split(' ', maxsplit=1)
                   if text_4[0] == "Арт" or text_4[0] == "арт" and text_4[1] == arts.name:
                           id = random.randint(arts.id_1, arts.id_2)
                           vk.method("messages.send",
                                     {
                                         "chat_id": event.object.peer_id - 2000000000,
                                         "attachment": "photo-" + f'{arts.art}' + f'{id}',
                                         "random_id": random.randint(1, 2147483647)
                                     })


name = "Нами"

if name == "Нами":
    id_1 = 103
    id_2 = 126
    art = "193643776_457239"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HexUserHex, 2020-05-16
@WolfInChains

I suspect that the problem is that when you add, you are trying to compare NOT already:

if text_4[0] == "Арт" or text_4[0] == "арт" and text_4[1] == 'Нами'

a
if text_4[0] == "Арт" or text_4[0] == "арт" and text_4[1] == ' Нами, Нами2'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question