+ 2
How can I solve the Symbols problem in Code Coach using Python?
The task is to get a string input consisting of words and numbers with random symbols in between and then output the string without the symbols. For example: Input: Al@
amp;+$+#ph$a B@$&e#&ta 12@#&$345 Output: Alpha Beta 12345 I am using Python's re module for this.7 Respostas
+ 4
It's also possible to do it with a simple for loop or with a comprehension.
+ 2
regex
u can use re.sub and remove the unwanted char
+ 2
input = "Al@amp;+$+#ph$a B@$&e#&ta 12@#&$345"
output = re.sub("[^\w\s]*", "", inp)
+ 1
đđąđąđđš đđĄđđČđđ„
Ayush Tripathi recheck fixed it
0
Here is a trick:
https://code.sololearn.com/cKh3wkM0cRvb/?ref=app
0
đđąđąđđš đđĄđđČđđ„ i provided him the regex split pattern.
If you are saying that, let him try his attempt. What he'll do? He can no further edit his code instead of just changing patterns.
he mentioned to use re module.
0
print(''.join(e for e in input() if e.isalnum() or e==' '))