+ 2

(Answered) Why isn't my spy life code passing test case 3

def strip_chars(str, chars): return "".join(c for c in str if c not in chars) x = input() print(strip_chars(x[::-1], "1234567890@@##$__&&--++//**::;;!!??~~``||••√√ππ÷÷×׶¶∆∆££¢¢€€¥¥^^°°==\\%%©©®®™™✓✓<<>>..,,"))

23rd Jun 2020, 4:22 PM
Hyperion
Hyperion - avatar
11 Respuestas
23rd Jun 2020, 5:35 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 3
I think you can do like this, def strip_chars(st): return "".join(c for c in st if c.isalpha() or c.isspace())
23rd Jun 2020, 5:25 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 2
What symbol am I missing
23rd Jun 2020, 4:22 PM
Hyperion
Hyperion - avatar
+ 2
Sorry I'm a beginner what will the re module do
23rd Jun 2020, 5:15 PM
Hyperion
Hyperion - avatar
+ 2
Thank you all so much
23rd Jun 2020, 5:49 PM
Hyperion
Hyperion - avatar
+ 2
OK, Nathan. There is no problem to be novice here. I mean regular expression library, it is imported as "import re" in the first line of your program. https://code.sololearn.com/cZoQ2etDRNxa/?ref=app
24th Jun 2020, 7:00 AM
Alexander Koval🇧🇾
Alexander Koval🇧🇾 - avatar
+ 2
I hide the line "x = input()" and added x from the challenge. You can uncomment it.
24th Jun 2020, 7:03 AM
Alexander Koval🇧🇾
Alexander Koval🇧🇾 - avatar
+ 1
You should import re.
23rd Jun 2020, 4:49 PM
Alexander Koval🇧🇾
Alexander Koval🇧🇾 - avatar
+ 1
Nathan, I am confused asking: why did you write twice every symbol in chars?
24th Jun 2020, 8:30 PM
Alexander Koval🇧🇾
Alexander Koval🇧🇾 - avatar
+ 1
It wasn't working with singular on my computer's IDE and I read somewhere if you repeat some symbols it would work
24th Jun 2020, 8:32 PM
Hyperion
Hyperion - avatar
0
Would be it not easier to turn over your solution and test a character if it is letter or space?
23rd Jun 2020, 4:38 PM
JaScript
JaScript - avatar