D
D
Dmitry Malikov2020-06-13 02:48:57
Python
Dmitry Malikov, 2020-06-13 02:48:57

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

1 answer(s)
D
DevMan, 2020-06-13
@Noobpython2134

elementary: fix the indents.
only for this you will have to familiarize yourself with the basics of python.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question