Please help me out šŸ„ŗ | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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