P
P
Privet1232022-04-02 15:58:55
Python
Privet123, 2022-04-02 15:58:55

How to solve indentation error problem?

import telebot
import config
import sqlite3

bot = telebot.TeleBot(config.TOKEN)

db = sqlite3.connect('bot_db')
cursor = sqlite3.cursor()

cursor.execute("""CREATE TABLE IF NOT EXISTS users(
    login text,
    password text
  )""")

db.commit()

@bot.message_handler(commands=['start'])
def get_login(message):
  sent = bot.send_message(message.chat.id, "Введите логин: ")
    bot.register_next_step_handler(sent, login)

def login(message):
  login = message.text

def get_password(message):
  mess = bot.send_message(message.chat.id, "Введите пароль: ")
    bot.register_next_step_handler(mess, password)

def password(message):
  password = message.text

def reg(message):
  cursor.execute(f"SELECT login FROM users WHEN login = '{login}'")
  if cursor.fetchone() is None:
    cursor.execute("INSERT INTO users VALUES (?, ?)", (login, password))
    db.commit()

    bot.send_message(message.chat.id, 'Вы успешно зарегистрированы!')
  else:
    bot.send_message(message.chat.id, 'Такой пользователь уже существует!')

bot.polling(none_stop=True)


File "C:\Users\1\Desktop\other_projects\test_login_bot\bot.py", line 20
    bot.register_next_step_handler(sent, login)
                                               ^
IndentationError: unindent does not match any outer indentation level
PS C:\Users\1\Desktop\other_projects\test_login_bot>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Chetchasov, 2022-04-02
@Privet123

in the 20th line there are 2 extra spaces before bot
, by the way, in the 27th too

S
Sergey Gornostaev, 2022-04-02
@sergey-gornostaev

Correctly place indents.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question