P
P
polmit2020-06-01 18:19:51
Python
polmit, 2020-06-01 18:19:51

UPD: Error inconsistent use of tabs and spaces in indentation on the line after final_message how to fix it?

from covid import Covid
import telebot
import config 


bot = telebot.TeleBot(config.TOKEN)
covid = Covid()

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
  bot.reply_to(message, "Начнем")

@bot.message_handler(content_types=['text'])
def start(message):
  final_message = ""
  get_message_bot = message.text.strip().lower()
  if get_message_bot == "США":
    location = covid.get_status_by_country_name("us")
  elif get_message_bot == "Украина":
    location = covid.get_status_by_country_name("Ukraine")
  elif get_message_bot == "Россия":
    location = covid.get_status_by_country_name("russia")
  elif get_message_bot == "Беларусь":
    location = covid.get_status_by_country_name("Belarus")
  elif get_message_bot == "Казахстан":
    location = covid.get_status_by_country_name("Kazakhstan")
  elif get_message_bot == "Италия":
    location = covid.get_status_by_country_name("italy")
  elif get_message_bot == "Франция":
    location = covid.get_status_by_country_name("france")
  elif get_message_bot == "Германия":
    location = covid.get_status_by_country_name("Germany")
  elif get_message_bot == "Япония":
    location = covid.get_status_by_country_name("Japan")
    final_message = f"<u>Данные по стране:</u>\n<b>Заболевших: </b>{location['confirmed']:,}\n<b>Умерших: </b>{location['deaths']:,}\n<b>Выздоровевших: </b>{location['recovered']:,}\n<b>Болеющих: </b>{location['active']:,}"
  else:
      location = covid.get_status_by_country_name("russia")
    
  bot.send_message(message.chat.id, final_message, parse_mode='html')

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-06-01
@hottabxp

else is not on the same level as if and elif

A
Alexander, 2020-06-01
@swwso1

Indentation must be respected, align the else as well as elif. And also translate errors)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question