Ask coding questions

← Back to all posts
Issue with splitting a message
JasmineSaliba (0)

My code says there's a Value error with my integer.

Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 72, in on_message
index = int(msg.split("~delete inspiration~ ",1)[1])
ValueError: invalid literal for int() with base 10: 'love you'

Comments
hotnewtop
Coder100 (18939)

As you may know, love you is not a number. So rethink why you wanted to put int to turn it into an int.
By the way, as a reminder, arrays start at 0 if you are indexing it wrong.

InvisibleOne (3227)

It's because you are trying to convert and string to an int, which doesn't work.