What can I do to not save whitespace in the list? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What can I do to not save whitespace in the list?

Just save word https://code.sololearn.com/c82NbwvcJQWe/?ref=app

21st Oct 2020, 10:29 AM
Ahmad
5 Answers
+ 9
i think you need something like this: x= ''.join(input('input text: ').split()) print(x)
21st Oct 2020, 11:05 AM
Lothar
Lothar - avatar
+ 2
That's right, but if someone wants to write this method , what should he do? I would like to learn
21st Oct 2020, 11:21 AM
Ahmad
+ 1
Do you want to split the string into a list? Just use the split method.
21st Oct 2020, 11:00 AM
QTWizard
+ 1
x=input('input text') list1=[] b="" for i in x: if i!=" ": b+=i list1.append(b) print(list1)
21st Oct 2020, 11:03 AM
Abhay
Abhay - avatar
0
Of course, it does not run well on my sololern
21st Oct 2020, 10:31 AM
Ahmad