About module of telebot

Hi all,

I was hoping the community could help me with an error I am getting with the dictionary ‘questions’ (I am a newbie, so any help would be much appreciated).
See the whole code, then see the screenshot of the code so that you can find where the errors are at lines 20 and 24:

#START
bot = telebot.TeleBot(‘******************************************’)
@bot.message_handler(commands=[‘start’])
def start_message(message):
bot.reply_to(message, “Welcome to the Quiz Bot! Please answer the following questions:”)
# Questions and answers stored in a dictionary
questions = {
“What is the answer of question 1”: “A”,
“What is the answer of question 2”: “B”,
“What is the answer of question 3”: “C”
}
# Start the question answering loop
current_question = next(iter(questions))
bot.send_message(message.chat.id, current_question)

@bot.message_handler(func=lambda message: True)
def answer_question(message):
global current_question
# Check if the user’s answer is correct for the current question
correct_answer = questions[current_question]
if message.text.lower() == correct_answer.lower():
bot.reply_to(message, “Correct!”)
# Move on to the next question
current_question = next(iter(questions), None)
if current_question:
bot.send_message(message.chat.id, current_question)
else:
bot.send_message(message.chat.id, “Congratulations! You have answered all the questions correctly.”)
else:
bot.reply_to(message, "Incorrect. The answer is " + correct_answer + “.”)

bot.polling()

#STOP

Nobody has an idea?

Please first read the pinned thread in order to understand how to post the code with proper formatting. That way, we only need to see the code once, and we can also copy and paste it in our own posts with proper formatting. Then we can more easily discuss the code and show fixes.

A screenshot is not very helpful for us; if the question is just “why did it underline questions in the code?”, then you can just describe that problem. (But I should warn now, from what I can see, many other things need to be fixed before this code can work the way you want it to.)

If you get errors from running the code (not from the program that you are using to edit the code), then you should copy and paste them so that we can see them exactly - and format them the same way as the code. (Python’s exception messages are designed to look right in the kind of “typewriter” font that we use for code. In particular, it will use ^ symbols to “underline” parts of the text.)

questions is local to start_message, and I think current_question is too.