Answer the question
In order to leave comments, you need to log in
An error in the code..?
I tried to make a bot about the weather and when I start it I get an error expected an indented block- indentation error how to fix it?
import pyowm
import telebot
owm = pyowm.OWM('...', language = "ru")
bot = telebot.TeleBot( ":..." )
@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 = "В городе " + message.text + " сейчас " + w.get_detailed_status() + "/n"
answer += "Температура сейчас в районе" + str(temp) + "/n/n"
if temp < -20:
answer += "Очень холодно, одевай меховые штаны, теплую кофту и куртку!"
elif temp < -10:
answer += "Довольно холодно, одевай теплые штаны кофту и куртку."
elif temp < 0:
answer += "Холодновато, одевай утепленные штаны и теплую кофту или футболку и ветровку."
elif temp < 10:
answer += "Довольно тепло, одевай штаны и кофту."
elif temp < 20:
answer += "Тепло, одевай шорты и футболку."
else:
answer += 'Иди, голый'
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