Answer the question
In order to leave comments, you need to log in
Why is the output of (x.transfer_ru()) and (x.lengwich_selection) different and how to fix it?
import requests, bs4
letters_ru = ("б", "п", "в", "ф", "д", "т", "з", "с", "ж", "ш", "ч", "ц", "щ", "г", "к", "х", "м", "н", "л", "р")
class Translate():
def __init__(self):
self.word = input("Введите слово:")
self.word = self.word.lower()
self.link = "https://wooordhunt.ru/word/" + self.word
self.link = requests.get(self.link)
self.link = bs4.BeautifulSoup(self.link.text, "html.parser")
def lengwich_selection(self): #Определение языка на котором написано слово
self.word_list = list(self.word)
if letters_ru in self.word_list:
return self.transfer_ru()
def transfer_eng(self): #Перевод с английского на русский
self.translate_link = self.link.select(".t_inline_en")
self.translate = self.translate_link[0].getText()
return ("Перевод слова - ") + self.translate.strip()
def transfer_ru(self): #Перевод с русского языка
self.translate_link = self.link.select(".t_inline")
self.translate = self.translate_link[0].getText()
return ("Перевод слова - ") + self.translate.strip()
def transkription(self): #Транскрипция (в том случае если язык английский)
self.transkription_word = self.link.select(".transcription")
self.transkription_amer = self.transkription_word[0].getText()
self.transkription_brit = self.transkription_word[1].getText()
return self.transkription_amer.strip(), self.transkription_brit.strip()
x = Translate()
print(x.transfer_ru())
print(x.lengwich_selection())
Answer the question
In order to leave comments, you need to log in
oh-my-selection returns None if it doesn't find a list of all Russian letters in the list of words . And since words are made up of strings, and no string is a tuple of Russian letters, oh my God, the selection always returns None.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question