J
J
JewrySoft2020-05-11 20:46:37
Python
JewrySoft, 2020-05-11 20:46:37

What is the problem with this error?

This error pops up:

ValueError: invalid literal for int with base 10 '79999999999 4'


The code where the error was:
def get_number(message):
    if int(message.text):
        try:
            if len(int(message.text)) == "13":
                haha = int(message.text)[12:]
                if haha < 5:
                    bot.send_message(message.chat.id, '<b>✉️Началось</b>', parse_mode='HTML')

            if len(int(message.text)) == "14":
                haha = int(message.text)[13:]
                if haha < 5:
                    bot.send_message(message.chat.id, '<b>✉️Началось</b>', parse_mode='HTML')
        except:
            bot.send_message(message.chat.id, 'Произошла ошибка!', reply_markup=home)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Botsman, 2020-05-11
@JewrySoft

You have a string '79999999999 4' that you are trying to convert to int:
int('79999999999 4')
You can, for example, remove the space character in this string:
s = '79999999999 4'
s = s.replace(' ', ' ')
int(s)
But then you also have invalid code:
int(message.text)[12:]
An int cannot be sliced ​​`[12:]`

S
Sergey Gornostaev, 2020-05-11
@sergey-gornostaev

Obviously 10 '79999999999 4'it's not a number.

V
Vadim Shatalov, 2020-05-11
@netpastor

In spaces - in spaces in lines, in spaces of knowledge of python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question