How can I remove new lines and tab space from this string at once? s = 'This\nis\PYthon\n\tlanguage' | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

How can I remove new lines and tab space from this string at once? s = 'This\nis\PYthon\n\tlanguage'

s = 'This\nis\PYthon\n\tlanguage' (after the s.split('\n'), s converts to a list and I cannot split it again from \t. Also, I cannot split it from \t\n at once)

13th Sep 2017, 9:32 AM
SobiX
SobiX - avatar
5 ответов
+ 3
s.replace("\n","") s.replace("\t","")
13th Sep 2017, 9:55 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
Or s.replace(x,"") for x in ("\n","\t")
13th Sep 2017, 9:55 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
in 'at once' mode, the for loop was no good.
13th Sep 2017, 10:36 AM
SobiX
SobiX - avatar
0
s = s.replace('\n'). Grazie.
13th Sep 2017, 10:29 AM
SobiX
SobiX - avatar
0
join, remove, translate.... didn't do the work.
13th Sep 2017, 10:34 AM
SobiX
SobiX - avatar