+ 1

Please help me out 🥺

на вход я получаю список, на выходе мне нужно получить этот список без букв ё и Ё at the input I get a list, at the output I need to get this list without the letters ё and Ё https://code.sololearn.com/cijkbH1K5iX1/?ref=app

21st Oct 2022, 2:10 AM
Murrr
8 Respuestas
+ 2
x=['Ёж', 'зелёный', 'ЕЁ', 'гЁТЬёсЮёёзЪЁЁЙ'] def replacer(x): s=[] for i in x: if 'ё' in i and 'Ё'in i: m=i.replace('ё','е') m =m.replace('Ё','Е') #edit use m, not i elif 'Ё'in i: m=i.replace('Ё','Е') elif 'ё' in i: m=i.replace('ё','е') s.append(m) return s #x=input().split(', ') print(replacer(x))
21st Oct 2022, 9:02 AM
Jayakrishna 🇮🇳
+ 6
murrr , to replace various characters, we can use 2 very nice string methods in python: > str.maketrans(...) defines character pairs in a dict. these pairs are converted to unicode id's > str.translate(...) is used to take a dict (created by maketrans()), and applies the replacement to a string you can find a sample how it works in the attached file: https://code.sololearn.com/cweDcS7bHqO6/?ref=app
21st Oct 2022, 5:54 PM
Lothar
Lothar - avatar
+ 2
I updated code. use, need to use updated m in place of I in first if.. m=i.replace('ё','е').replace('Ё','Е')
21st Oct 2022, 9:53 AM
Jayakrishna 🇮🇳
+ 2
I just gave working code but actually there you don't need to check condition.. This codes works same as your original. x=['Ёж', 'зелёный', 'ЕЁ', 'гЁТЬёсЮёёзЪЁЁЙ'] s = [] for i in x : m = i.replace('ё','е').replace('Ё','Е') s.append(m) print(s) #or simply , can be in one line. s = [ i.replace('ё','е').replace('Ё','Е') for i in x ] print(s)
21st Oct 2022, 6:58 PM
Jayakrishna 🇮🇳
+ 1
But it still prints ё in words where both ё and Ë meet
21st Oct 2022, 9:46 AM
Murrr
+ 1
It works THANKS A LOT !!!!
21st Oct 2022, 11:10 AM
Murrr
+ 1
Wow, thanks
21st Oct 2022, 5:55 PM
Murrr
+ 1
Thanks 👍
21st Oct 2022, 6:59 PM
Murrr