Answer the question
In order to leave comments, you need to log in
Why is there an error in the indentation?
The problem is indentation, while I looked at the code several times, and everything is in order (I do not use tabs when indenting).
def get_current_item(chat_id, category=''):
if category == '':
user = select_call("SELECT * FROM users WHERE id={};".format(chat_id))[0]
status = user['status']
item_id, category = status.split(',')
item_id = int(item_id) + 1
else:
item_id = 1
item = select_call("SELECT * FROM catalog WHERE category='{}' AND id={};".format(category, item_id))
if len(item) == 0:
item_id = 1
item = select_call("SELECT * FROM catalog WHERE category='{}' AND id={};".format(category, item_id))
item = item[0]
msg = '*{}*\n\nМедиа: {}.'.format(item['name'], item['media'])
status = '{}, {}'.format(item_id, category)
update_call("UPDATE users SET status=%s WHERE id=%s;", (status, chat_id))
return msg, item['pic_path']
Answer the question
In order to leave comments, you need to log in
Remove all indents and redo them from scratch. You screwed up with the size of the omissions.
Look at the code you attached to the question before the screenshots . There you use 2 spaces for indentation, then 4 . Do it right, in the same style.
Your indentation confusion starts with the line "if len(item) == 0:", fix it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question