Answer the question
In order to leave comments, you need to log in
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
in the 20th line there are 2 extra spaces before bot
, by the way, in the 27th too
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question