M
M
Maxim Samonov2021-08-27 10:51:46
Python
Maxim Samonov, 2021-08-27 10:51:46

Why does it always throw an error in Python code?

Here is the code itself, I checked it through the command line and it always throws an error:
bot.send_messages(message.chat.id, answer)
Name error: name 'mesaage' is not defined
import pyowm
import telebot

owm=pyowm.OWM('token ', language = 'en')

bot = telebot.TeleBot('token')

@bot.message_handler(content_types=['text'])
def send_echo(message):
observation = owm.weather_at_place(message.text)
w = observation .get_weather()
temp=w.get_temperature('celsius')['temp']

answer = 'City ' + message.text + ' now ' + w.get_detailed_status() + '\n'
answer += 'Temperature in ' + str(round(temp)) + 'degrees' + '\n\n'

if temp<10:
answer += 'It's very cold, dress warmly))'
elif temp<17:
answer += 'Cool, better dress up:)'
else:
answer += 'It's not cold, even if you go in shorts :)'

bot.send_message(message. chat.id, answer)

bot.polling(none_stop = True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksandr, 2021-08-27
@Maks_432

Judging by the error, there is a spelling error in the code. But I didn’t find it in the code above, either this is not the whole code, or you corrected it before publishing. Name error: name 'mesaage' is not defined

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question