Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question