V
V
Vlad Tanashchuk2020-06-25 19:59:47
Python
Vlad Tanashchuk, 2020-06-25 19:59:47

How to take a certain number of words from the user's text?

Hello, I am doing a "multi-kick" command and it is necessary that after this command a certain number of words be taken, and if this number is exceeded, an error will come out.
I tried this, but everything is mixed into one list:

text = event.obj['text'].split(' ', maxsplit=1)
if text[0] == "мульти-кик":
   print(text[1:])

It comes out something like this:
5ef4d817da29e553626898.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-25
@Xaeruz

words = event.obj['text'].split(' ')
if len(words) > 5:
    print('Ошибка')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question