S
S
samperirrrrr2020-12-14 20:06:51
Python
samperirrrrr, 2020-12-14 20:06:51

How to check for the second word in a message?

Hello everyone, I have a question here. How to check for the second word in a message? Here is an example of "casino"
and supposedly if there is no second word in the message, then they will write. "Look" Casino (amount) ""
I tried to do something like this

args = event.object.text.lower().split()
if args[1] is None:
send_msg(id,"Введите казино (сумма)"

But it doesn't work. This is how it is in JS.
if(!args[0]) {
ctx.send('что то вводи')
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-12-14
@samperirrrrr

If you have already broken the text into words, it would be logical to check the length of the list.

if len(args) < 2:
    # ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question